S
s0suk3
I've read that the only two ways to use setjmp without invoking
undefined behavior are
- as the expression in an expression statement,
- as part of the controlling expression in an if, switch, while, do,
or for statement. The entire controlling expression must have one of
the following forms, where constexpr is an integer constant expression
and op is a relational or equality operator:
setjmp(...)
!setmp(...)
constexpr op setjmp(...)
setjmp(...) op constexpr
If that's correct, then a simple assignment like this would cause
undefined behavior:
rv = setjmp(env); // where 'env' is a jmp_buf and 'rv' is an int
Well, that's the theory. What about the practice? Are there actually
any compilers where this might go wrong? I'm primarily interested in
Visual C++.
Sebastian
undefined behavior are
- as the expression in an expression statement,
- as part of the controlling expression in an if, switch, while, do,
or for statement. The entire controlling expression must have one of
the following forms, where constexpr is an integer constant expression
and op is a relational or equality operator:
setjmp(...)
!setmp(...)
constexpr op setjmp(...)
setjmp(...) op constexpr
If that's correct, then a simple assignment like this would cause
undefined behavior:
rv = setjmp(env); // where 'env' is a jmp_buf and 'rv' is an int
Well, that's the theory. What about the practice? Are there actually
any compilers where this might go wrong? I'm primarily interested in
Visual C++.
Sebastian