This discussion is archived
1 Reply Latest reply: Jan 24, 2013 9:31 AM by C Project Lead RSS

C99 interpretation bug in c99 compiler?

zootle Newbie
Currently Being Moderated
This code snippet came up on a recent Usenet discussion:

struct toto { const int i; const float f; const void *p; };

struct toto foo(int i, float f, void *p)
{
return (struct toto){i, f, p};
}

and the consensus was it should compile, but c99 reports:

left operand must be modifiable lvalue: op "="

for the return statement.

6.8.6.4 p3 states

"the value of the expression is returned to the caller as the value of the function call expression"

and the footnote for that section reads

"The return statement is not an assignment. The overlap restriction of subclause 6.5.16.1 does not apply to the case of function return".

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points