S
Seebs
While reading up on some of the stuff in C:TCR, I've found something which
looks as though it used to be an error but possibly isn't.
Consider:
int main(void) {
struct { int a, b; } x, y;
x.a = 10;
y = x;
return 0;
}
Is the behavior of this program well-defined? My assumption would have been
that it was not, because x.b was indeterminate and accessed through an lvalue
of non-character type. However, C99 TC3 says (6.2.6.1, paragraph 3):
"the value of a structure or union object is never a trap
representation, even though the value of a member of the structure
or union may be a trap representation".
That looks as though, after the assignment, no undefined behavior has occurred,
but it is possible that y.b is a trap representation. Interestingly, it looks
as though this might be true even if y had been fully initialized before the
assignment from x.
Thoughts?
-s
looks as though it used to be an error but possibly isn't.
Consider:
int main(void) {
struct { int a, b; } x, y;
x.a = 10;
y = x;
return 0;
}
Is the behavior of this program well-defined? My assumption would have been
that it was not, because x.b was indeterminate and accessed through an lvalue
of non-character type. However, C99 TC3 says (6.2.6.1, paragraph 3):
"the value of a structure or union object is never a trap
representation, even though the value of a member of the structure
or union may be a trap representation".
That looks as though, after the assignment, no undefined behavior has occurred,
but it is possible that y.b is a trap representation. Interestingly, it looks
as though this might be true even if y had been fully initialized before the
assignment from x.
Thoughts?
-s