Is the GNUC dialect anything that GCC does when given source code containing UB? (Was: More C type errors by default for GCC 14)

Eli Schwartz
Fri May 12 11:48:59 GMT 2023

On 5/12/23 1:57 AM, Po Lu wrote:
> Eli Schwartz <> writes:
>> It's still no big deal, no matter how much you dramatize the intensity
>> of adding a flag to your Makefiles.
> It's extra work.  Why don't I just write:
>   extern int foo ();
> above each of the new errors?
> That is just about what anyone will do when confronted by these new
> errors.  As a result, you have not ensured that any declarations are
> correct, but instead you have annoyed a lot of people and lulled
> yourself into a false sense of safety.

Instead of adding one flag to their Makefile, which is too much work,
they will add *many* declarations of `extern int foo();` across many
source files in the same project?

Very interesting definition of burdensome work.

You keep saying "just about what anyone will do", but I do not believe
this is what anyone other than you will do.

> This document is the GCC manual, which makes reference (not too clearly,
> however, which should be fixed) to both implicit int and implicit
> function declarations, which are allowed in C99 and later dialects of C.
> These constructs are not bugs.  These constructs explicitly defined by
> GNU C; since a diagnostic is issued, GNU C's implementation also
> conforms to the Standard.

You reading is faulty, and your beliefs about how software work are also
faulty, if you believe that the issuance of a diagnostic is what
constitutes adding new features to the language dialect called "GNU C".

Please start a new thread, titled something like "the documentation is
flawed, which should be fixed, because implicit function declarations
are referenced but not to clearly". Argue there, that implicit function
declarations should be documented on the "C Extensions" page.

Until everyone is on the same page as you about whether these are GNUC
extensions, this conversation will go nowhere.

>> You cannot, and are not permitted, to define "how GCC currently behaves"
>> as "defines what is valid GNU C". No one agrees with your analysis. Most
>                                     ^^^^^^
> I'm not a person?

"no one agrees with you" is a common idiom that states that a person (in
this case Po Lu) holds an opinion that rest of the world (all persons
not named Po Lu) do not hold.

Since you cannot agree with yourself -- you are yourself -- I am forced
to believe that you are trolling by accusing me of denying you personhood.

>> importantly, GCC does not agree with your analysis.
> For some definition of GCC, which is apparently you.

No, just the GCC manual.

>> It's a wild, wild, wild claim to begin with. You are arguing that any
>> bug, ANY bug whatsoever, which qualifies for the title "how GCC
>> currently behaves" because if a bug is currently present, then GCC
>> currently behaves in a buggy manner...
>> ... any such bug is, ***because*** GCC currently does it, now part of
>> the documentation on "GNU C", a language dialect with documentation.
>> Can you show me where on
>> the GCC
>> documentation states that "C Extensions include anything that GCC
>> currently does, no matter what, no matter how documented or undocumented"?
> I see:
> `-Wno-implicit-int (C and Objective-C only)'
>      This option controls warnings when a declaration does not specify a
>      type.  This warning is enabled by default in C99 and later dialects
>      of C, and also by `-Wall'.
> `-Wno-implicit-function-declaration (C and Objective-C only)'
>      This option controls warnings when a function is used before being
>      declared.  This warning is enabled by default in C99 and later
>      dialects of C, and also by `-Wall'.  The warning is made into an
>      error by `-pedantic-errors'.

Irrelevant, I shall ignore this comment -- it is not listed on the "C
Extensions" page.

>> The concept of a language extension has bulletproof meaning. You cannot
>> get around it, redefine it, pretend that something is when it isn't, or
>> otherwise disagree with this bulletproof meaning.
> The concept of a ``language extension'' is not defined anywhere.
> Instead, there are three kinds of behavior not precisely specified by
> the Standard:

The concept of a language extension is defined by the page that says
"these are the extensions to the language". Please take your mendacious
reading of the C standard and put it back where you got it from.

>   - undefined behavior, the behavior upon use of an erroneous construct
>     for which the Standard imposes no requirements whatsoever.
>   - unspecified behavior, where upon the use of a construct for which
>     the Standard imposes two or more possible behaviors, and leaves the
>     selected behavior unspecified.
>   - implementation-defined behavior, unspecified behavior where each
>     implementation documents how the choice is made, and is required to
>     document that choice.
> If the translator precisely defines either undefined behavior (in this
> case, erroneous syntax) or unspecified behavior, then that definition is
> commonly considered to be an extension of that translator.  Nothing
> says will change that.

... because the GNUC language dialect is not synonymous with either
undefined, unspecified, or implementation defined behavior. Quoting
random definitions of things that aren't "C Extensions" don't make them
C Extensions.

I also find it difficult to understand how adding a diagnostic telling
you not to do something would be synonymous with "precisely defines"
doing that thing. There's nothing precise about it?

"Nothing says will change that". What? Please tell me how this
can be so. What precisely defines the behavior if not the manual?
Defining something is to create a description of that thing. English
language prose is the standard for creating descriptions. That's the
documentation. What else are you looking at here?

> GNU C documentation does not decide what is an extension and what is
> not.

I am framing this and putting it on my wall.

> In any case, if (gcc)C Extensions does not mention extensions
> currently implemented by GCC, then that is a bug in the documentation,
> is it not?  Documentation is supposed to reflect what the program being
> documented does, not the other way around.  Like the Standard says:
>   An implementation shall be accompanied by a document that defines all
>   implementation- defined and locale-specific characteristics and all
>   extensions.

Please submit a bug report to GCC requesting that this be added to a
section titled "implementation-defined and locale-specific characteristics".

Do not expect it to be added to a section titled "C Extensions to the
language, which shall be known as the acceptable GNUC dialect".

>> You are not writing GNU C code, you never have been. GNU C code is
>> defined by the documentation for GNU C:
>> You may take this as me dictating to you that you are not to call this
>> code "GNU C".
> Really?  Then why is __GNUC__ defined, and why does it compile with
> `gcc'?

Why does C++ compile with `gcc` as long as it has the right heuristic
file extension?

Why is __GNUC__ defined when you specifically ask for -std=c89, which is
not -std=gnu89?

I assume because the compiler is kind and forgiving, and will often
allow you to mix dialects even though you shouldn't, if it can be done
safely and without conflicting other stds.

But implicit-function-declarations cannot be done safely.


This discussion is going nowhere until you accept that GNUC has a
definition and that definition is separate from "what GCC does when
given UB".

Eli Schwartz

More information about the Gcc mailing list