Bug 89966 - [9 Regression] non-type template argument rejects sizeof operator result
Summary: [9 Regression] non-type template argument rejects sizeof operator result
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-04 13:42 UTC by Pekka S
Modified: 2019-04-05 03:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build: 9.0.1 20190404
Known to work:
Known to fail:
Last reconfirmed: 2019-04-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pekka S 2019-04-04 13:42:20 UTC
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()'
Comment 1 Jason Merrill 2019-04-05 02:51:24 UTC
Author: jason
Date: Fri Apr  5 02:50:52 2019
New Revision: 270160

URL: https://gcc.gnu.org/viewcvs?rev=270160&root=gcc&view=rev
Log:
	PR c++/89966 - error with non-type auto tparm.

My patch for PR 86932 broke this testcase by passing tf_partial to
coerce_template_template_parms, which prevented do_auto_deduction from
actually replacing the auto.

	* pt.c (do_auto_deduction): Clear tf_partial.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1z/nontype-auto15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
Comment 2 Jason Merrill 2019-04-05 03:05:59 UTC
Fixed.