E
essai
Hi all,
In the book "C A reference manual" (Samuel P. Harbison III & Guy L.
Steele Jr) p.455, it is said:
"Standard C requires that the call to setjmp either be ..., the right-
hand side of a simple assignment expression, or ..."
I looked at the standard and found:
"Environmental limits
4 An invocation of the setjmp macro shall appear only in one of the
following contexts:
— the entire controlling expression of a selection or iteration
statement;
— one operand of a relational or equality operator with the other
operand an integer
constant expression, with the resulting expression being the entire
controlling
expression of a selection or iteration statement;
— the operand of a unary ! operator with the resulting expression
being the entire
controlling expression of a selection or iteration statement; or
— the entire expression of an expression statement (possibly cast to
void).
5 If the invocation appears in anyother context, the behavior is
undeï¬ned."
So, according to the Standard C, a statement like this:
jmp_buf env;
int status = setjmp(env);
leads to undefined behaviour, but according to Harbison and Steele, is
perfectly defined.
Who's right? who's wrong?
Thanks by advance, all.
In the book "C A reference manual" (Samuel P. Harbison III & Guy L.
Steele Jr) p.455, it is said:
"Standard C requires that the call to setjmp either be ..., the right-
hand side of a simple assignment expression, or ..."
I looked at the standard and found:
"Environmental limits
4 An invocation of the setjmp macro shall appear only in one of the
following contexts:
— the entire controlling expression of a selection or iteration
statement;
— one operand of a relational or equality operator with the other
operand an integer
constant expression, with the resulting expression being the entire
controlling
expression of a selection or iteration statement;
— the operand of a unary ! operator with the resulting expression
being the entire
controlling expression of a selection or iteration statement; or
— the entire expression of an expression statement (possibly cast to
void).
5 If the invocation appears in anyother context, the behavior is
undeï¬ned."
So, according to the Standard C, a statement like this:
jmp_buf env;
int status = setjmp(env);
leads to undefined behaviour, but according to Harbison and Steele, is
perfectly defined.
Who's right? who's wrong?
Thanks by advance, all.