aaron.ballman added inline comments.
================ Comment at: clang/test/Sema/constant-builtins-ilogb.cpp:1 +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics ---------------- hubert.reinterpretcast wrote: > There seems to be no C language test in the patch (although the builtin > presumably is okay at least as part of arithmetic constant expressions). > > @aaron.ballman, what are your thoughts re: integer constant expression > contexts? For example: > ``` > struct C { int x : __builtin_ilogb(1. + 1.); }; > ``` WG14 adopted https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2713.htm for C2x to clarify that implementations are not allowed to extend what they consider to be an integer constant expression. The operand in this case is a function call expression, which is not one of the permissible things in an ICE, so the standard doesn't want us to make it one. I believe that Clang's response to that paper is to implement it to the letter rather than to the intent. e.g., issue a warning that a constant expression is being folded into an ICE but otherwise accept the code. We have too many situations already in which we fold a constant expression to an ICE and changing that behavior would be observable (and a performance regression). So I think it's fine for us to treat the builtin call as an ICE so long as we issue a (pedantic) warning about folding it. (FWIW, I don't think it qualifies as an arithmetic constant expression because that also doesn't allow function call expressions. But we can extend the definition of an arithmetic constant expression.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136568/new/ https://reviews.llvm.org/D136568 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits