-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"cwg-issueAn issue that was filed to the Core Working GroupAn issue that was filed to the Core Working Groupwaiting-for-wg21Blocked on C++ Standards CommitteeBlocked on C++ Standards Committee
Description
Bugzilla Link | 48407 |
Version | unspecified |
OS | Linux |
CC | @AaronBallman,@DougGregor,@efriedma-quic,@zygoloid |
Extended Description
gcc-11 will deliberately become stricter and will disallow non-constant expressions in offsetof: https://gcc.gnu.org/#95942
Complete example:
// $ cat.bug.cc
struct a {
int b;
char c[100];
};
unsigned long d(long e) { return __builtin_offsetof(a, c[e]); }
$ g++-11.0.0 -c bug.cc -o bug.o
bug.cc: In function 'long unsigned int d(long int)':
bug.cc:6:60: error: 'e' is not a constant expression
6 | unsigned long d(long e) { return __builtin_offsetof(a, c[e]); }
| ^
$ clang++-11 -c bug.cc -o bug.o
<ok>
Should clang also reject the code above? If not should clang emit warning on -Wall
that non-standard extension is being used?
Thank you!
frederick-vs-ja
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"cwg-issueAn issue that was filed to the Core Working GroupAn issue that was filed to the Core Working Groupwaiting-for-wg21Blocked on C++ Standards CommitteeBlocked on C++ Standards Committee