Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What will this C code do?

Name: Anonymous 2012-01-19 8:24

void main(){
int x=1;
printf("%d\n",x=2);
}

Name: Anonymous 2012-01-21 15:19

>>59
When would you ever shift an integer by a value greater than or equal to its width? The article didn't say pointer aliasing would lead to undefined behaviour. Just that converting a pointer to an incompatible type and then dereferencing it would.

>>60
You're right, but what do translation units have to do with it?

>>65
As mentioned, it's only undefined for automatic variables. The standard says:
If an object that has static storage duration is not initialized explicitly, then:
— if it has pointer type, it is initialized to a null pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to these rules;
— if it is a union, the first named member is initialized (recursively) according to these rules.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List