Is uu = uu = vv UB

N

Noob

Hello everyone,

The following code (probably a typo) elicits a warning from GCC.

int main(void)
{
int uu, vv = 0;
uu = uu = vv;
return 0;
}

$ cc -Wall foo.c
foo.c: In function 'main':
foo.c:4: warning: operation on 'uu' may be undefined

I imagine what the author meant to write was
uu = uu & vv; (or some other bit-wise operator)
but instead wrote
uu = uu = vv;

For my information, does the statement
uu = uu = vv;
have undefined behavior?

I would say the behavior is well-defined.

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top