[cfe-dev] How can I use the result of a void expression? :p

Keith Bauer onesadcookie at gmail.com
Sun Aug 26 04:39:13 PDT 2007


imac:Desktop keith$ cat > conditionalvoid.c
extern void foo();
extern void bar();
void baz(int c) {
  c ? foo() : bar();
}
imac:Desktop keith$ gcc -fsyntax-only -Wall -Wextra conditionalvoid.c
imac:Desktop keith$ clang -fsyntax-only conditionalvoid.c
conditionalvoid.c:4:3: warning: expression result unused
  c ? foo() : bar();
  ^~~~~~~~~~~~~~~~~
1 diagnostic generated.

( ?: on void is perfectly legal according to C99 6.5.15 )

-Keith



More information about the cfe-dev mailing list