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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
struct S { int a; int b[15]; };

int
foo (int n)
{
  int m = n;
  return __builtin_offsetof (S, b[m]);
}

has been rejected for years, while
struct S { int a; int b[15]; };

int
foo (int n)
{
  return __builtin_offsetof (S, b[n]);
}
has been accepted.
The comment in cp/parser.c says:
  /* ??? For offsetof, there is a question of what to allow here.  If
     offsetof is not being used in an integral constant expression context,
     then we *could* get the right answer by computing the value at runtime.
     If we are in an integral constant expression context, then we might
     could accept any constant expression; hard to say without analysis.
     Rather than open the barn door too wide right away, allow only integer
     constant expressions here.  */

Reply via email to