[Bug c++/90426] [P0732] Error constructing non-type template parameter from a prvalue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426 --- Comment #6 from Marek Polacek --- I posted a patch to improve diagnostics for this particular case: https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00529.html
[Bug c++/90426] [P0732] Error constructing non-type template parameter from a prvalue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426 --- Comment #5 from Mateusz Pusz --- (In reply to Mateusz Pusz from comment #3) > (In reply to Marek Polacek from comment #1) > > This compiles if I use {} instead of (): > > > > struct gram : unit {}; > > (In reply to Marek Polacek from comment #2) > > I think this is invalid. [temp.arg]p2: > > "In a template-argument, an ambiguity between a type-id and an expression is > > resolved to a type-id, regardless of the form of the corresponding > > template-parameter." > > > > template > > struct S { }; > > > > struct R { }; > > > > void > > g (void) > > { > > S s; // template argument treated as function type > > S s2; > > S s3; // template argument treated as function type > > S s4; > > } > > Please note that all of the following compiles fine and is not treated as a > function type (most vexing parse) > > constexpr auto r1(ratio(std::milli())); > constexpr auto r2(ratio(std::milli())); > constexpr ratio r3(std::milli()); My bad, that actually is a most vexing parse issue. Sorry!
[Bug c++/90426] [P0732] Error constructing non-type template parameter from a prvalue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426 --- Comment #4 from Mateusz Pusz --- (In reply to Marek Polacek from comment #1) > This compiles if I use {} instead of (): > > struct gram : unit {}; I know that it compiles fine in the following cases: struct gram : unit {}; struct gram : unit {}; // not treated as a function type struct gram : unit {}; So the only one lacking is: struct gram : unit {};
[Bug c++/90426] [P0732] Error constructing non-type template parameter from a prvalue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426 --- Comment #3 from Mateusz Pusz --- (In reply to Marek Polacek from comment #1) > This compiles if I use {} instead of (): > > struct gram : unit {}; (In reply to Marek Polacek from comment #2) > I think this is invalid. [temp.arg]p2: > "In a template-argument, an ambiguity between a type-id and an expression is > resolved to a type-id, regardless of the form of the corresponding > template-parameter." > > template > struct S { }; > > struct R { }; > > void > g (void) > { > S s; // template argument treated as function type > S s2; > S s3; // template argument treated as function type > S s4; > } Please note that all of the following compiles fine and is not treated as a function type (most vexing parse) constexpr auto r1(ratio(std::milli())); constexpr auto r2(ratio(std::milli())); constexpr ratio r3(std::milli());
[Bug c++/90426] [P0732] Error constructing non-type template parameter from a prvalue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Marek Polacek --- I think this is invalid. [temp.arg]p2: "In a template-argument, an ambiguity between a type-id and an expression is resolved to a type-id, regardless of the form of the corresponding template-parameter." template struct S { }; struct R { }; void g (void) { S s; // template argument treated as function type S s2; S s3; // template argument treated as function type S s4; }
[Bug c++/90426] [P0732] Error constructing non-type template parameter from a prvalue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #1 from Marek Polacek --- This compiles if I use {} instead of (): struct gram : unit {};