public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52748] New: [C++11] N3276 changes to decltype
@ 2012-03-28  5:33 zeratul976 at hotmail dot com
  2012-08-09  8:09 ` [Bug c++/52748] " lundberj at gmail dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: zeratul976 at hotmail dot com @ 2012-03-28  5:33 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52748
           Summary: [C++11] N3276 changes to decltype
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeratul976@hotmail.com


The C++11 standard section 5.2.2 pararaph 11 states that:

"If a function call is a prvalue of object type [and] if the function call is
[...] the operand of a decltype-specifier [...], a temporary object is not
introduced for the prvalue. The type of the prvalue may be incomplete. [Note:
as a result, storage is not allocated for the prvalue and it is not destroyed;
thus, a class type is not instantiated as a result of being the type of a
function call in this context." 

This addition was made late in the C++11 standardization process; its rationale
is described in the paper N3276 [1]

It seems GCC does not currently support this. In fact, when run on the "trivial
example" given in N3276, GCC gets into an infinite loop and, if left running,
uses up all the memory in the system (!) (Should I file that as a separate
issue?)

Here is the example (WARNING - may exhaust your system's virtual memory if
you're not careful):

template<class T> struct S;
template<class X, class Y> struct pair {};
template<class T> S<T> wrap(T) { return 0; }
template<class T>
struct S
{
   S(int = 0) {}
   decltype(wrap(pair<T,T>())) foo() { return 0; } // ERROR
   S<pair<T,T> > bar() { return 0; } // OK
};
S<int> s;


[1] http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3276.pdf


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

end of thread, other threads:[~2013-04-16 21:24 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28  5:33 [Bug c++/52748] New: [C++11] N3276 changes to decltype zeratul976 at hotmail dot com
2012-08-09  8:09 ` [Bug c++/52748] " lundberj at gmail dot com
2012-08-10  9:39 ` redi at gcc dot gnu.org
2012-11-07  4:31 ` zeratul976 at hotmail dot com
2012-11-07  4:32 ` zeratul976 at hotmail dot com
2013-02-18 12:47 ` redi at gcc dot gnu.org
2013-02-26 20:21 ` jason at gcc dot gnu.org
2013-03-17  2:38 ` jason at gcc dot gnu.org
2013-03-23 10:52 ` paolo.carlini at oracle dot com
2013-03-26 14:31 ` jason at gcc dot gnu.org
2013-03-28 13:11 ` mimomorin at gmail dot com
2013-03-28 13:29 ` [Bug c++/52748] [4.9 Regression][C++11] " paolo.carlini at oracle dot com
2013-03-28 13:36 ` jason at gcc dot gnu.org
2013-03-28 20:03 ` jason at gcc dot gnu.org
2013-03-29  0:41 ` mimomorin at gmail dot com
2013-04-10  9:27 ` zeratul976 at hotmail dot com
2013-04-11 21:46 ` jason at gcc dot gnu.org
2013-04-12  7:23 ` zeratul976 at hotmail dot com
2013-04-16 21:24 ` jason at gcc dot gnu.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).