Fixed const qualifiers on named structs/unions members that should prevent assignments to the whole structs/unions.
Added warning on ignored qualifiers on anonymous structs/unions.
This commit is contained in:
25
test/err/bug2018.c
Normal file
25
test/err/bug2018.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Bug #2018 - Compiler has problems with const struct fields */
|
||||
|
||||
struct X {
|
||||
struct {
|
||||
int a;
|
||||
} a;
|
||||
union {
|
||||
int a;
|
||||
const int b;
|
||||
} b;
|
||||
};
|
||||
|
||||
struct X f(void)
|
||||
{
|
||||
struct X x = { 42 };
|
||||
return x;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct X x = { 0 };
|
||||
x = f(); /* Error since X is read only */
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user