public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27403] T() can be an integer constant but is rejected as not one
       [not found] <bug-27403-4@http.gcc.gnu.org/bugzilla/>
@ 2012-02-08 20:17 ` pinskia at gcc dot gnu.org
  2013-01-19 14:23 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-08 20:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27403

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-08 20:16:38 UTC ---
t4.cc:4:17: error: type/value mismatch at argument 1 in template parameter list
for ‘template<int <anonymous> > struct A’
t4.cc:4:17: error:   expected a constant of type ‘int’, got ‘T()’


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/27403] T() can be an integer constant but is rejected as not one
       [not found] <bug-27403-4@http.gcc.gnu.org/bugzilla/>
  2012-02-08 20:17 ` [Bug c++/27403] T() can be an integer constant but is rejected as not one pinskia at gcc dot gnu.org
@ 2013-01-19 14:23 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-19 14:23 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27403

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

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-19 14:22:55 UTC ---
Wolfgang is right, the testcase is invalid, T() is parsed as a function type,
not an expression that value-initializes a T.

[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."

i.e. it doesn't matter that the argument is expecting a non-type parameter of
type int, because T() can be a type-id it is interpreted as one.

(This happened to be discussed last month on the committee reflectors)

Using T{} in C++11 works because that cannot be a type-id and is unambiguously
an initialization of T.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/27403] T() can be an integer constant but is rejected as not one
  2006-05-02 21:12 [Bug c++/27403] New: " pinskia at gcc dot gnu dot org
@ 2006-05-26 15:26 ` bangerth at dealii dot org
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2006-05-26 15:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2006-05-26 15:26 -------
gcc parses this as

template <class T>
typename A<T (&)()  >::I foo (T) { return 0; }

i.e. as meaning that the argument is not an integer, but a function that
returns an integer.

A simpler testcase is this (icc accepts it, though I'm not sure who's right):
-------------------
template <int> struct A {};
A<int()> foo (int);
-------------------

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27403


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-19 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-27403-4@http.gcc.gnu.org/bugzilla/>
2012-02-08 20:17 ` [Bug c++/27403] T() can be an integer constant but is rejected as not one pinskia at gcc dot gnu.org
2013-01-19 14:23 ` redi at gcc dot gnu.org
2006-05-02 21:12 [Bug c++/27403] New: " pinskia at gcc dot gnu dot org
2006-05-26 15:26 ` [Bug c++/27403] " bangerth at dealii dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).