[llvm-bugs] [Bug 34630] New: __builtin_offsetof doesn't allow scope qualifiers
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 15 12:36:21 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34630
Bug ID: 34630
Summary: __builtin_offsetof doesn't allow scope qualifiers
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: myriachan at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
The following code does not compile, with a syntax error:
#include <cstddef>
struct A { int x; };
struct B { };
struct C : A, B { };
int meow()
{
return offsetof(C, A::x);
}
error: expected ')'
Whether this should be allowed in C++ is an interesting question. C++ defers
to C, which says a "member-designator" here, but then doesn't define that.
(There's a WG14 defect report somewhere on this, to be fixed for C2x?)
Normally, this wouldn't be necessary, because the first parameter should be a
standard-layout type, which can't have non-static members of conflicting names.
But pretty much every compiler supports offsetof() on everything but virtual
inheritance cases, so people use it. (Also, there's a C++ proposal in the
works to formally allow offsetof for any class not involving the word
"virtual".)
GCC allows this.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170915/0f8236ff/attachment.html>
More information about the llvm-bugs
mailing list