Bug 58910 - std::Tuple_impl is non constexpr when using identical userdefined structs as template-args
Summary: std::Tuple_impl is non constexpr when using identical userdefined structs as ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P2 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2013-10-29 11:57 UTC by Gaetano Checinski
Modified: 2015-11-25 10:02 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.1.0, 6.0
Known to fail:
Last reconfirmed: 2013-10-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gaetano Checinski 2013-10-29 11:57:24 UTC
Following code does not compile with gcc-snapshot(2013-10-21) :

#include <tuple>
using namespace std;
struct t1{ constexpr t1(){} };
struct t2{ constexpr t2(){} };


int main()
{
 constexpr t1 T1;
 constexpr t2 T2;
 constexpr tuple<t1,t2> Tup1(T1,T2);
 constexpr tuple<t1,t1> Tup2(T1,T1);
 constexpr auto a=get<0>(Tup1 ); //works fine
 constexpr auto b=get<0>(Tup2 ); // error: 
//'(const std::_Head_base<0ul, t1, true>*)(& Tup2)' 
//is not a constant expression constexpr auto b=get<0>(Tup2 );

return 0;
}
Comment 1 Paolo Carlini 2013-10-29 13:25:15 UTC
This is a regression and I don't think we changed anything in the library?!? Looks like a C++ regression then, and we would need a reduced testcase.
Comment 2 Paolo Carlini 2013-10-29 14:26:09 UTC
Sorry, in fact this isn't a regression. Still the issue seems serious in terms of impact on <tuple> use. I also note that with the same <tuple> implementation, clang++ accepts the testcases, thus seems definitely a front-end issue.
Comment 3 Ville Voutilainen 2015-02-18 17:43:21 UTC
I can't reproduce this bug with the current trunk.
Comment 4 Paolo Carlini 2015-11-25 09:53:48 UTC
Indeed. Let's play safe and add a testcase before closing the bug as fixed for 5+.
Comment 5 paolo@gcc.gnu.org 2015-11-25 10:00:34 UTC
Author: paolo
Date: Wed Nov 25 10:00:02 2015
New Revision: 230860

URL: https://gcc.gnu.org/viewcvs?rev=230860&root=gcc&view=rev
Log:
2015-11-25  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58910
	* g++.dg/cpp0x/constexpr-tuple2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-tuple2.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 6 Paolo Carlini 2015-11-25 10:02:13 UTC
Done.