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

            Bug ID: 113653
           Summary: Failure to diagnose use of (non-constant-expr) const
                    objects in static initializers
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx
  Target Milestone: ---

The following is a constraint violation:

int foo()
{
    static const int x = 1;
    static const int y = x; // not a constant expression
    return y;
}

However, gcc does not diagnose it as such, even with -Wall -Wextra.

This appears to have been a regression somewhere between the gcc 4 era and now.

I'm not sure what component this should be assigned to. I chose "c" because
it's C-specific that this is not a constant expression; it would be in C++.

Reply via email to