Language
C++
Compiler
gcc HEAD 13.0.1 20230307 (experimental)
Options
Warnings
Don't Use Boost
C++2b(GNU)
no pedantic
$ g++ prog.cc -Wall -Wextra -std=gnu++2b
prog.cc: In instantiation of 'constexpr decltype (X) const_pow() [with auto X = 100000000; auto E = 0; decltype (X) = int]':
prog.cc:6:73: recursively required from 'constexpr decltype (X) const_pow() [with auto X = 100; auto E = 1; decltype (X) = int]'
prog.cc:6:73: required from 'constexpr decltype (X) const_pow() [with auto X = 10; auto E = 3; decltype (X) = int]'
prog.cc:11:32: required from here
prog.cc:6:62: warning: integer overflow in expression of type 'int' results in '1874919424' [-Woverflow]
6 | return !E ? 1 : 1 == E ? X : (E % 2 ? X : 1) * const_pow<X * X, E / 2>();
| ~~^~~
prog.cc:6:73: error: no matching function for call to 'const_pow<(100000000 * 100000000), (0 / 2)>()'
6 | return !E ? 1 : 1 == E ? X : (E % 2 ? X : 1) * const_pow<X * X, E / 2>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
prog.cc:4:23: note: candidate: 'template<auto X, auto E> constexpr decltype (X) const_pow()'
4 | constexpr decltype(X) const_pow() noexcept
| ^~~~~~~~~
prog.cc:4:23: note: template argument deduction/substitution failed:
prog.cc:6:73: error: overflow in constant expression [-fpermissive]
6 | return !E ? 1 : 1 == E ? X : (E % 2 ? X : 1) * const_pow<X * X, E / 2>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
prog.cc:6:73: error: overflow in constant expression [-fpermissive]
prog.cc:6:62: note: in template argument for type 'int'
6 | return !E ? 1 : 1 == E ? X : (E % 2 ? X : 1) * const_pow<X * X, E / 2>();
| ~~^~~
Exit Code:
1