Can I safely use return inside GCC expression statement operators?
For example, I define a macro
#define CHECK_FUNC_RESULT(func) \ ({ \ int result = func(); \ if (!result) return; \ result; \ })
and use it somewhere in the code this way:
int function1() { if (some_condition) return 0; ... return 1; } void function2() { if(CHECK_FUNC_RESULT(function1)) { ... to do something } }
Is it possible to expect a return from function2 (on some_condition == true) without any undefined behavior?
source share