[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics
    Mital Ashok via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Tue Aug 22 08:00:01 PDT 2023
    
    
  
MitalAshok marked an inline comment as done.
MitalAshok added inline comments.
================
Comment at: clang/test/SemaCXX/varargs.cpp:34
   enum Unscoped1 { One = 0x7FFFFFFF };
-  (void)__builtin_va_arg(ap, Unscoped1); // ok
+  (void)__builtin_va_arg(ap, Unscoped1); // expected-warning {{second argument to 'va_arg' is of promotable type 'Unscoped1'; this va_arg has undefined behavior because arguments will be promoted to 'int'}}
 
----------------
Unscoped1 is promoted to int when passed to a variadic function.
The underlying type for Unscoped1 is unsigned int, so only Unscoped1 and unsigned int are compatible, not Unscoped1 and int. An Unscoped1 passed to a variadic function must be retrieved via va_arg(ap, int).
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156054/new/
https://reviews.llvm.org/D156054
    
    
More information about the cfe-commits
mailing list