[llvm-bugs] [Bug 48755] New: clang permits write to const anonymous struct members
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 14 12:11:05 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=48755
Bug ID: 48755
Summary: clang permits write to const anonymous struct members
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C
Assignee: unassignedclangbugs at nondot.org
Reporter: ndesaulniers at google.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Blocks: 4068
Via this LKML thread:
https://lore.kernel.org/lkml/20210114175934.13070-1-will@kernel.org/T/#m1328d75e335d7e58bdd670ca30fea062b738f408
(Reported-by: Will Deacon <will at kernel.org>)
struct foo {
const struct {
int bar;
};
} my_foo;
struct foo2 {
const struct {
int bar;
} named;
} my_foo2;
void baz (void) {
my_foo.bar = 42; // GCC errors, clang does not
my_foo2.named.bar = 42; // GCC and Clang error
}
Marking `bar` as const qualified is a portable workaround, for now.
https://godbolt.org/z/h7qPxd
Referenced Bugs:
https://bugs.llvm.org/show_bug.cgi?id=4068
[Bug 4068] [Meta] Compiling the Linux kernel with clang
--
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/20210114/b1aa2f9a/attachment.html>
More information about the llvm-bugs
mailing list