public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113804] New: offsetof(type, array[run_time_value]) failing
@ 2024-02-07 12:03 jlame646 at gmail dot com
  2024-02-07 12:27 ` [Bug c++/113804] " jakub at gcc dot gnu.org
  2024-02-07 15:06 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jlame646 at gmail dot com @ 2024-02-07 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113804
           Summary: offsetof(type, array[run_time_value]) failing
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following code starts failing in gcc but is accepted by clang and msvc. 

```
#include <cstddef>

struct type {
    int array[4];
};

int main(int argc, char**) {
    return offsetof(type, array[argc]);
}
```

GCC says: 

```
In file included from
/opt/compiler-explorer/gcc-trunk-20240207/include/c++/14.0.1/cstddef:50,
                 from <source>:1:
<source>: In function 'int main(int, char**)':
<source>:8:33: error: 'argc' is not a constant expression
    8 |     return offsetof(type, array[argc]);
      |              
```

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

end of thread, other threads:[~2024-02-07 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 12:03 [Bug c++/113804] New: offsetof(type, array[run_time_value]) failing jlame646 at gmail dot com
2024-02-07 12:27 ` [Bug c++/113804] " jakub at gcc dot gnu.org
2024-02-07 15:06 ` pinskia 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).