https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69035
Bug ID: 69035 Summary: [constexpr] Using bultins sometimes make the expression non-constant Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- Hello, I have a problem when using builtins (like __builtin_clz()) inside constexpr functions. Example: constexpr int foo(int x) { return __builtin_clz(x); } Using foo(<constant>) as a constant-expression results in the following error: char tab[foo(1)]; // error: size of array ‘tab’ is not an integral constant-expression However, if I add something to the foo(1) (and this something is not zero) it starts to work: char tab[foo(1)+1]; // no error. Using __builtin_clz() directly also works: char tab[__builtin_clz(1)]; // no error. As does adding 1 inside foo(): constexpr int foo2(int x) { return __builtin_clz(x) + 1; } char tab[foo(1)]; // no error. The clang compiler does not produce these errors and works with every example provided here.