[Bug c/122050] statement expressions with an empty expression at the end have different behavior between C and C++

jsm28 at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Sep 24 14:23:14 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122050

--- Comment #4 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
I'd expect it to be void unless the compound statement is nonempty and the last
thing in it is an expression statement with an expression (possibly also with
labels or attributes before that expression). That is, it should be void if it
ends with an empty statement, or a declaration, or a label, or any kind of
statement other than an expression statement. I think this says that C is wrong
in this case (and has been wrong as far back as 2.7.2.3).


More information about the Gcc-bugs mailing list