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

            Bug ID: 89966
           Summary: [9 Regression] non-type template argument rejects
                    sizeof operator result
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p...@gcc-bugzilla.mail.kapsi.fi
  Target Milestone: ---
             Build: 9.0.1 20190404

Hi.

This has appeared within the last four weeks or so.  It seems that not all
operators are affected as e.g. alignof(...) works just fine in the same
context.  Maybe this has something do with the sizeof(...) internals rather
than non-type template parameters / arguments?


$ cat ntta__sizeof.cpp
template < auto a0 >
void f0() { }
void f0_call() { f0< sizeof(int) >(); }

$ g++.exe -Wall -Wextra -std=c++17 -fconcepts -c ntta__sizeof.cpp
ntta__sizeof.cpp: In function 'void f0_call()':
ntta__sizeof.cpp:3:36: error: no matching function for call to 'f0<sizeof
(int)>()'
    3 | void f0_call() { f0< sizeof(int) >(); }
      |                                    ^
ntta__sizeof.cpp:2:6: note: candidate: 'template<auto a0> void f0()'
    2 | void f0() { }
      |      ^~
ntta__sizeof.cpp:2:6: note:   template argument deduction/substitution failed:
ntta__sizeof.cpp: In substitution of 'template<auto a0> void f0() [with auto a0
= sizeof (int)]':
ntta__sizeof.cpp:3:36:   required from here
ntta__sizeof.cpp:3:36: error: integral expression 'sizeof (int)' is not
constant
    3 | void f0_call() { f0< sizeof(int) >(); }
      |                                    ^
ntta__sizeof.cpp:3:36: error:   trying to instantiate 'template<auto a0> void
f0()'

Reply via email to