public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking
@ 2013-03-28 21:22 w.shane.grant at gmail dot com
  2013-03-28 23:57 ` [Bug c++/56774] [4.7/4.8/4.9 Regression] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: w.shane.grant at gmail dot com @ 2013-03-28 21:22 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56774
           Summary: G++ 4.8 reverses variadic template types during
                    unpacking
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: w.shane.grant@gmail.com


In g++ 4.8, it seems as if variadic templates are reversed when being unpacked.
 Consider the following minimal example:

#include <tuple>
#include <iostream>

template <class T, class ... OtherT>
void something( std::tuple<T, OtherT...> & tup )
{
  std::cout << std::get<1>(tup) << std::endl;
}

int main()
{
  std::tuple<int, char, bool> myTuple(3, 'a', true);

  // Compiles OK in GCC 4.6.3 but NOT 4.8
  something<int, char, bool>( myTuple );

  // Compiles OK in GCC 4.8 but NOT 4.6.3
  something<int, bool, char>( myTuple );

  return 0;
}

The output of this, if the appropriate line is commented out, will be: 'a'.  To
get code that previously worked under 4.6.3, the template parameters that will
be unpacked have to be reversed.

See relevant Stack Overflow post here:
http://stackoverflow.com/questions/15692112/gcc-4-8-is-reversing-variadic-template-parameter-pack


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

* [Bug c++/56774] [4.7/4.8/4.9 Regression] G++ 4.8 reverses variadic template types during unpacking
  2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
@ 2013-03-28 23:57 ` paolo.carlini at oracle dot com
  2013-03-29  0:09 ` d.frey at gmx dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-28 23:57 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-03-28
            Summary|G++ 4.8 reverses variadic   |[4.7/4.8/4.9 Regression]
                   |template types during       |G++ 4.8 reverses variadic
                   |unpacking                   |template types during
                   |                            |unpacking
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-28 23:57:30 UTC ---
We badly need a reduced testcase not using the whole <tuple> (not to mention
<iostream> of course)


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

* [Bug c++/56774] [4.7/4.8/4.9 Regression] G++ 4.8 reverses variadic template types during unpacking
  2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
  2013-03-28 23:57 ` [Bug c++/56774] [4.7/4.8/4.9 Regression] " paolo.carlini at oracle dot com
@ 2013-03-29  0:09 ` d.frey at gmx dot de
  2013-03-29  0:17 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: d.frey at gmx dot de @ 2013-03-29  0:09 UTC (permalink / raw)
  To: gcc-bugs


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

Daniel Frey <d.frey at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |d.frey at gmx dot de

--- Comment #2 from Daniel Frey <d.frey at gmx dot de> 2013-03-29 00:09:10 UTC ---
Here's a reduced testcase without any includes:

template< typename... > struct tuple {};

template< typename T, typename... Ts >
void f( tuple< T, Ts... >& ) {}

int main()
{
   tuple< int, bool, char > t;
   f< int, char, bool >(t);
}

This compiles with GCC 4.7.2 and GCC 4.8.0, but it shouldn't.
GCC 4.6.3 and Clang 3.2 reject the code as expected.

Output from GCC 4.6.3:

Compilation finished with errors:
source.cpp: In function 'int main()':
source.cpp:9:26: error: no matching function for call to 'f(tuple<int, bool,
char>&)'
source.cpp:9:26: note: candidate is:
source.cpp:4:6: note: template<class T, class ... Ts> void f(tuple<T, Ts ...>&)


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

* [Bug c++/56774] [4.7/4.8/4.9 Regression] G++ 4.8 reverses variadic template types during unpacking
  2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
  2013-03-28 23:57 ` [Bug c++/56774] [4.7/4.8/4.9 Regression] " paolo.carlini at oracle dot com
  2013-03-29  0:09 ` d.frey at gmx dot de
@ 2013-03-29  0:17 ` paolo.carlini at oracle dot com
  2013-03-29  0:21 ` w.shane.grant at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-29  0:17 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-29 00:17:49 UTC ---
Thanks a lot Daniel. Let's CC Jason.


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

* [Bug c++/56774] [4.7/4.8/4.9 Regression] G++ 4.8 reverses variadic template types during unpacking
  2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
                   ` (2 preceding siblings ...)
  2013-03-29  0:17 ` paolo.carlini at oracle dot com
@ 2013-03-29  0:21 ` w.shane.grant at gmail dot com
  2013-03-29 18:33 ` jason at gcc dot gnu.org
  2013-03-30  0:31 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: w.shane.grant at gmail dot com @ 2013-03-29  0:21 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Shane <w.shane.grant at gmail dot com> 2013-03-29 00:21:32 UTC ---
(In reply to comment #1)
> We badly need a reduced testcase not using the whole <tuple> (not to mention
> <iostream> of course)

Here's a more reduced test case.

template <class ... Args>
struct mytype {};

template <class T, class ... Args>
void something( mytype<T, Args...> )
{ }

int main()
{
  // Compiles OK in GCC 4.6.3 but NOT 4.8
  something<int, char, bool>( mytype<int, char, bool>() );

  // Compiles OK in GCC 4.8 but NOT 4.6.3
  something<int, bool, char>( mytype<int, char, bool>() );

  return 0;
}

I tried to make simpler cases using purely variadic templates (e.g. no class
T), but the issue only shows up when there is an individually named template
parameter as well as a variadic pack.  To get the error to show up it also
requires types that cannot be implicitly converted to each other.


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

* [Bug c++/56774] [4.7/4.8/4.9 Regression] G++ 4.8 reverses variadic template types during unpacking
  2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
                   ` (3 preceding siblings ...)
  2013-03-29  0:21 ` w.shane.grant at gmail dot com
@ 2013-03-29 18:33 ` jason at gcc dot gnu.org
  2013-03-30  0:31 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2013-03-29 18:33 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/56774] [4.7/4.8/4.9 Regression] G++ 4.8 reverses variadic template types during unpacking
  2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
                   ` (4 preceding siblings ...)
  2013-03-29 18:33 ` jason at gcc dot gnu.org
@ 2013-03-30  0:31 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2013-03-30  0:31 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.3

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2013-03-30 00:31:50 UTC ---
Fixed for 4.7.3/4.8.1/4.9.


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

end of thread, other threads:[~2013-03-30  0:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 21:22 [Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking w.shane.grant at gmail dot com
2013-03-28 23:57 ` [Bug c++/56774] [4.7/4.8/4.9 Regression] " paolo.carlini at oracle dot com
2013-03-29  0:09 ` d.frey at gmx dot de
2013-03-29  0:17 ` paolo.carlini at oracle dot com
2013-03-29  0:21 ` w.shane.grant at gmail dot com
2013-03-29 18:33 ` jason at gcc dot gnu.org
2013-03-30  0:31 ` 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).