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

--- Comment #2 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
(In reply to jos...@codesourcery.com from comment #1)
> I wonder if this is yet another issue with macros from system headers 
> (bool being defined in a system header to expand to _Bool) ...

Looks like it is. In gimplify.c:gimplify_va_arg_expr we have:

      /* Unfortunately, this is merely undefined, rather than a constraint      
         violation, so we cannot make this an error.  If this call is never     
         executed, the program is still strictly conforming.  */                
      warned = warning_at (loc, 0,                                              
                           "%qT is promoted to %qT when passed through
%<...%>", 
                           type, promoted_type); 

And warning_at returns false. Also, for

#include <stdarg.h>
#define BOOL _Bool
void foo(va_list ap)
{
    va_arg(ap, BOOL);
}

GCC outputs:

In file included from test2.c:1:0:
test2.c: In function 'foo':
test2.c:2:14: warning: '_Bool' is promoted to 'int' when passed through '...'
 #define BOOL _Bool
              ^
test2.c:5:16: note: in expansion of macro 'BOOL'
     va_arg(ap, BOOL);
                ^
test2.c:2:14: note: (so you should pass 'int' not '_Bool' to 'va_arg')
 #define BOOL _Bool
              ^
test2.c:5:16: note: in expansion of macro 'BOOL'
     va_arg(ap, BOOL);
                ^
test2.c:2:14: note: if this code is reached, the program will abort
 #define BOOL _Bool
              ^
test2.c:5:16: note: in expansion of macro 'BOOL'
     va_arg(ap, BOOL);

IMHO, it would be more correct to output something like this:

test2.c: In function 'foo':
test2.c:5:16: warning: '_Bool' is promoted to 'int' when passed through '...'
     va_arg(ap, BOOL);
                ^
test2.c:2:14: note: expanded from macro 'BOOL'
 #define BOOL _Bool
              ^

Reply via email to