[PATCH] D136416: [AST] Support Bool type in va_arg
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 21 05:28:23 PDT 2022
aaron.ballman added a comment.
> Currently, if the second argument is "Bool", it will be casted to "int".
That behavior is required by the standard, which is why we give a warning about it being undefined behavior due to the promotion. For C, see C2x 7.16.1.1p2 ("If //type// is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined, except for the following cases: ..." and none of the cases apply to bool.) and for C++, see https://eel.is/c++draft/cstdarg.syn#1.sentence-4 which says the same thing in different words.
You'll see the same kind of UB if you try to use `short` instead of `bool`: https://godbolt.org/z/Kz95vbaY4
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136416/new/
https://reviews.llvm.org/D136416
More information about the cfe-commits
mailing list