[Bug c++/84403] Possible further extension of constexpr: allow to use them as template parameters

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 23 10:31:13 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84403

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Daniel Fruzynski from comment #0)
> Values in constexpr functions are known at compile time,

No, not necessarily. You can call a constexpr function with runtime values too:

#include <type_traits>

constexpr int test(int n)
{
    return std::integral_constant<int, n>::value;
}

int main(int argc, char**)
{
  return test(argc);
}

So this is impossible to do. Function parameters are never constant
expressions.


More information about the Gcc-bugs mailing list