1

I have no idea what is a conforming and a non-conforming compiler. I did google and tried to find the definition of conforming and non-conforming compiler, but unfortunately I couldn't find. So I have come here to know the definition of conforming and non-conforming compiler.

chqrlie
  • 131,814
  • 10
  • 121
  • 189
  • related: [C11 compiler conformance comparison](https://stackoverflow.com/q/17398487/9716597) – L. F. Apr 29 '21 at 02:18
  • 1
    For example: clang = conforming compiler; Turbo-C = non-conforming compiler; MSVC = not quite either? – Adrian Mole Apr 29 '21 at 08:26
  • 1
    @AdrianMole MSVC isn't a C compiler, hence only has limited C conformance. Its [C++ conformance](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-160) is great though, and has always been far ahead of gcc and clang [since C++14](https://en.cppreference.com/w/cpp/compiler_support) – phuclv Apr 29 '21 at 09:02
  • @phuclv MSVC is a C89 compiler and has a reasonable conformance level (although some glaring bugs in the stdio.h implementation) – M.M Apr 29 '21 at 11:15
  • @AdrianMole why is Turbo-C not a conforming compiler? can you elaborate this in much better way by giving some example (like some standard feature not supported by Turbo-C) – Abhishek Jaiswal Apr 30 '21 at 07:49
  • @AbhishekJaiswal Turbo C was released in 1987, and the first C standard is C89, so Turbo C has lots of differences and incompatibilities to the standard. Similarly Turbo C++ was released far before the first C++ standard (1990 vs 1998) so it bares almost nothing in the C++ standard – phuclv May 01 '21 at 03:44
  • is [this](https://stackoverflow.com/users/15536062/abhishek-jaiswal) you? Don't use multiple accounts, please [merge them](https://meta.stackoverflow.com/q/336512/995714). https://stackoverflow.com/help/merging-accounts – phuclv May 01 '21 at 04:05

3 Answers3

3

“Conform” means “comply with rules, standards, or laws.” In the context of C programming, a “conforming compiler” generally means a compiler that conforms to the rules of the C standard. “Conform” is a general English word; we can use it in other senses too, to say that compiler conforms to its own particular documentation, not just the C standard, or to rules set by a business contract or by various technical specifications. The context in which a phrase is used helps set its meaning.

The C standard specifies a number of rules for the syntax and grammar of C programs and for interpreting and executing them. A compiler that complies with these rules is a conforming compiler.

Actually, a compiler is just part of a C implementation. Complete C implementations typically including compiling source code to make object modules, linking object modules to make a program, and executing the program on computing hardware with an operating system and supporting software libraries. It requires all of these things to form a complete C implementation. However, we may say the compiler is conforming if it is doing its part in that.

The C standard specifies minimum rules that a conforming compiler must meet, but it also allows compilers to extend the C language by doing additional things that are not required in the C standard. Since extensions are allowed, a compiler with extensions may still be conforming.

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
  • A sensible answer that ties what is an actual English word to what it means in this and broader contexts both. I would always prefer an answer like yours to one that just throws more perverted terms at the problem which originated from confusing use of terms in the first place. Simplify, don't complicate. – Armen Michaeli Apr 29 '21 at 11:17
  • @Eric Postpischil Can you please give me few examples of non-conforming compiler and a better explanation for not being conforming compiler? – Abhishek Jaiswal Apr 30 '21 at 07:50
  • 1
    @AbhishekJaiswal: There is an example [here](https://stackoverflow.com/questions/19477310/why-errno-can-set-to-zero-by-scanfwhen-enter-ctrld/19478100#19478100). The C standard says none of the standard library routines set `errno` to zero, but the `scanf` routine was setting `errno` to zero in certain situations. So the C implementation was violating a rule of the C standard. Therefore, the C implementation did not conform to the standard. Conforming means obeying all the rules. – Eric Postpischil Apr 30 '21 at 20:40
  • @EricPostpischil Okay i appreciate your effort towards my understanding. But it would be much better for me if you give the name of some compiler which are non-conforming.. – Abhishek Jaiswal May 01 '21 at 02:23
  • 1
    @AbhishekJaiswal every compiler has its own non-standard compliant extensions. But most modern compilers have some options to disable that to be completely conforming – phuclv May 01 '21 at 03:48
  • @phuclv: Compliant extensions do not make a compiler non-conforming. They are **not** an example of non-conformance. The C standard permits and invites extensions. Providing an extension is conforming with the C standard. – Eric Postpischil May 01 '21 at 10:14
2

Mostly; "conforming" means "able to conform to everything in the C language specification (ignoring any optional configuration/settings, like the --fast_math command line flag in GCC)"; and "non-conforming" is everything else.

For "non-conforming", there's a common sense limit - e.g. if the compiler doesn't attempt to implement any of C (e.g. a Pascal compiler) then it's technically "non-conforming to the C specs" but it doesn't make much sense to state that. This creates a possible grey area (e.g. a new language that is very close to C but not intended to be identical to C).

For "conforming", there's also a common sense limit - e.g. if a C compiler just has one minor bug that (under extremely rare conditions) might cause it to produce the wrong ("non-conforming") output; then technically it's "non-conforming" but almost everyone will call it "conforming".

Brendan
  • 35,656
  • 2
  • 39
  • 66
1

These terms are in the context of the C Standard.

It would be a good idea to read all of Chapter 4 in the Standard, titled "Conformance" (it is only a single page). You can download a free draft using the above link. The first few pages of Chapter 5 are also relevant to this topic.

  • implementation is the formal term for the entire mechanism that takes a program's source code, and ends up executing the program. This usually consists of translation phases to produce an executable binary, and then execution of that binary.

  • When people say "the compiler", they usually mean all of the translation phases of the implementation, and talk about "compiling" a program for this entire translation process, resulting in an executable binary. But sometimes "the compiler" and "compiling" are used with a narrower meaning, restricted to a subset of the translation phase. This is covered in section 5.1.1 of the Standard.

  • conforming implementation is defined by section 5.1.2.3 (in Chapter 5). It means an implementation which can take any program, and execute it to produce output which is correct according to the output specified by the Standard for that program.

    • When people talk about "conforming compiler", it's implied that they refer to an implementation consisting of that compiler (and any related utilities) plus its target execution environment.
    • For some programs the Standard may specify that they may (or must!) fail translation, and/or that there is no defined behaviour upon execution. For such programs, translation failure or any output whatsoever is considered to be correct output.
M.M
  • 138,810
  • 21
  • 208
  • 365