14

Implementation-defined behaviors in C are unspecified behaviors for which each conforming implementation must document its choice.

I found such documentations easily for gcc here or Microsoft C here, but I can't find any such documentation for clang.

Am I searching wrong or is there no such thing?

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
pwilke
  • 151
  • 4
  • GCC does not document all implementation-defined behavior. E.g. it doesn't document the implementation-defined behavior in https://eel.is/c++draft/basic.stc#general-4: are uses of dangling pointers (other than dereferencing them) UB? – Blaisorblade Dec 10 '20 at 03:50

1 Answers1

9

This ticket https://github.com/llvm/llvm-project/issues/11644 is still opened (for many years now) so it seems that clang doesn't explicitly specify implementation defined behaviour.

For most cases I would bet that it's the same as GCC, though.

pipe
  • 657
  • 10
  • 27
dreamzor
  • 5,795
  • 4
  • 41
  • 61
  • 4
    So clang is not a conforming C compiler and it it even worse than Visual Studio? Oh that burns. Not even Borland Turbo C from 1990 is worse than Visual Studio... Normative term: 3.4.1 **implementation-defined behavior** unspecified behavior where each implementation documents how the choice is made. – Lundin Mar 31 '16 at 14:12
  • 1
    @Lundin: Yes, the lack of documentation makes it non-conforming. I wouldn't agree that that makes it "even worse than Visual Studio". (Though I haven't used VS enough to comment on its quality.) – Keith Thompson Mar 31 '16 at 16:30
  • @KeithThompson: Note that any compiler vendor who claims that programs which it accepts but processes in meaningful fashion are "non-conforming" would be admitting that their compiler isn't a conforming C impolementation, since the *definition* of "Conforming C Program" would be it impossible for a Conforming C Implementation to process anything that wasn't a Conforming C Program. – supercat Feb 08 '23 at 16:26
  • @supercat Not sure what you're saying. Most C compilers are non-conforming by default, and require extra options (`-std-c?? -pedantic`) to make them attempt to be fully conforming. Even a fully conforming C implementation can accept non-conforming code as long as it issues any required diagnostics. A *conforming program* is by definition "one that is acceptable to a conforming implementation" (it's not 100% clear what "acceptable" means). – Keith Thompson Feb 08 '23 at 17:22
  • @KeithThompson: The Standard's definition of "Conforming C Program" says that if there exists somewhere in the universe a program P such that P is a Conforming C Implementation and P accepts some source text S, then S is a Conforming C Program. This implies that if some program P' accepts some source text S, the only way for S not to be a Conforming C Program would be for P not to be a Conforming C Implementation. – supercat Feb 08 '23 at 17:29
  • @KeithThompson: Some people like to use some made-up category of "Standards-compliant" programs which is more narrower than "Conforming C Program", but broader than "Strictly conforming C Program", but the Standard doesn't recognize any such concept, much less exercise jurisdiction over what programs would or would not qualify, Some people believe the only "legitimate" programs are those over which the Standard exercises jurisdiction, but the Standard was never intended to partition all programs into those which are legitimate and those which aren't. – supercat Feb 08 '23 at 17:39