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

Alejandro Colomar <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foss+gcc@alejandro-colomar.
                   |                            |es

--- Comment #5 from Alejandro Colomar <[email protected]> ---
Consider this case:

alx@devuan:~/tmp$ cat foo.c
#define foo(x)                           \
({                                       \
        _Pragma("GCC diagnostic push");  \
        x;                               \
        _Pragma("GCC diagnostic pop");   \
})

int
main(void)
{
        return foo(42);
}

When the _Pragma() is removed, the trailing semicolon remains there.  If the C
behavior were wrong, this code would suddenly fail.

This code has been historically portable, and IMO should remain valid.

alx@devuan:~/tmp$ gcc-11 -Wall -Wextra foo.c; ./a.out; echo $?
42
alx@devuan:~/tmp$ gcc-16 -Wall -Wextra foo.c; ./a.out; echo $?
42
alx@devuan:~/tmp$ clang-18 -Wall -Wextra foo.c; ./a.out; echo $?
42
alx@devuan:~/tmp$ clang-21 -Wall -Wextra foo.c; ./a.out; echo $?
42

Reply via email to