4
votes

Consider the following:

typedef int;
int main () { return 0; }

If I compile this with clang with no warning specifications I get

warning: typedef requires a name [-Wmissing-declarations]
typedef int;

That's to be expected; typedef int is illegal per section 6.7 of the C11 standard, and per section 5.1.1.3,

A conforming implementation shall produce at least one diagnostic message if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint.

If I compile this using clang -Wno-missing-declarations, it compiles clean, without any diagnostic messages.

My question:
Does this mark clang as a non-conforming implementation, or is it okay to provide the ability to disable what would otherwise be mandatory diagnostics?

1
It seems to me that if anything, clang is conforming just fine and it allows you to specify a flag that makes your use of it non-conforming. - mah
GCC also allows this however you have to write some other non-conforming code (using implicit int in C99, for example) as quite a few such diagnostics don't have a name/option in GCC. - cremno
You could say that clang -Wno-missing-declarations is for all intents and purposes a different compiler than clang. Same for gcc -ansi -pedantic vs gcc. - ninjalj

1 Answers

3
votes

From the draft C11 standard section 4 Conformance we see that it is not strictly conforming:

A strictly conforming program shall use only those features of the language and library specified in this International Standard.3) It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior, and shall not exceed any minimum implementation limit.

but it is a conforming implementation since a conforming implementation is allowed to have extensions as long as they don't break a strictly conforming program:

[...]A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.4)

The C-FAQ says:

[...]There are very few realistic, useful, strictly conforming programs. On the other hand, a merely conforming program can make use of any compiler-specific extension it wants to.