https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124017

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|Incomplete/Misleading       |Incomplete/Misleading
                   |diagnostic locations for    |diagnostic locations for
                   |multiple undefined labels   |the same undefined label in
                   |in goto statements          |multiple goto statements
   Last reconfirmed|                            |2026-02-08
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So we only error out on the last goto where the undefined label is used.

If we change the testcase to use different labels then GCC errors out on each
line where the different label is used.

I think this is actually decent because we don't know if you miss-spelled the
label or just forgot to define it. Once you define the label, all of the goto
will just work.


This is the opposite of undeclared indentifiers where only the first rather
than the last one is errored out on. THis is also opposite than what clang does
here where the first rather than last one is errored out on.

>In large, machine-generated, or complex files (like the attached case), this 
>behavior forces a "trial-and-error" debugging process where the developer 
>fixes one line only to have the compiler "discover" the previous one in a 
>subsequent pass.

Even erroring out on all of them is not good either because it could just be
not having the lable defined yet. and that is an diagnostic issue too.

I am not sure which of the 3 ways is better here: first, last or all usage. All
have their benifits and have pitfalls.

Now the location for the error message should be fixed/improved no matter what.
So confirmed on that.

Reply via email to