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

            Bug ID: 95942
           Summary: [11 regression] offsetof on an array: error: 'e' is
                    not a constant expression
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at inbox dot ru
  Target Milestone: ---

The original error is seen on https://www.dolphin-emu.org/ project as a build
error. Minimized example looks the following:

"""
  // $ cat.bug.cc
  struct a {
    int b;
    char c[100];
  };
  unsigned long d(long e) { return __builtin_offsetof(a, c[e]); }
"""

OK:
  $ LANG=C g++-10.1.0 -c bug.cc -o bug.o

OK:
  $ LANG=C clang++-10 -c bug.cc -o bug.o

FAIL:
  $ LANG=C g++-11.0.0 -c bug.cc -o bug.o
  bug.cc: In function 'void d(long int)':
  bug.cc:8:42: error: 'e' is not a constant expression
      8 | void d(long e) { __builtin_offsetof(a, c[e]); }
        |

Who is wrong here? gcc-10 or gcc-11?

Reply via email to