public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99577] New: Non-constant (but actually constant) initializers referencing other constants no longer diagnosed as of GCC 8
@ 2021-03-13 13:55 harald at gigawatt dot nl
  2021-03-15  8:36 ` [Bug c/99577] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: harald at gigawatt dot nl @ 2021-03-13 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99577
           Summary: Non-constant (but actually constant) initializers
                    referencing other constants no longer diagnosed as of
                    GCC 8
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harald at gigawatt dot nl
  Target Milestone: ---

GCC 8 and newer no longer issue an error for

  const int i = 0;
  const int j = i;

Up until GCC 7, this resulted in

test.c:2:15: error: initializer element is not constant
 const int j = i;
               ^

As in the similar (and perhaps related?) bug #66618, the standard does not
require a diagnostic for this code, but this code is not portable, it gets
rejected by some other compilers, so an option in GCC to diagnose this would be
useful.

This bug is the opposite of bug #53091, which asks for this to be accepted and
was never updated after GCC started to accept it. As noted in that bug, clang
accepts this as well without any diagnostic. I will report it as an issue to
them too, if it has not been reported already.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/99577] Non-constant (but actually constant) initializers referencing other constants no longer diagnosed as of GCC 8
  2021-03-13 13:55 [Bug c/99577] New: Non-constant (but actually constant) initializers referencing other constants no longer diagnosed as of GCC 8 harald at gigawatt dot nl
@ 2021-03-15  8:36 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-15  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-03-15
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |accepts-invalid, diagnostic

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  A diagnostic would be nice.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-15  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 13:55 [Bug c/99577] New: Non-constant (but actually constant) initializers referencing other constants no longer diagnosed as of GCC 8 harald at gigawatt dot nl
2021-03-15  8:36 ` [Bug c/99577] " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).