https://bugs.llvm.org/show_bug.cgi?id=48407
Bug ID: 48407
Summary: Consider forbidding non-constant expressions in
offsetof
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
gcc-11 will deliberately become stricter and will disallow non-constant
expressions in offsetof: https://gcc.gnu.org/PR95942
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!
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs