Patchwork [C++,testcase,committed] PR 55708

login
register
mail settings
Submitter Paolo Carlini
Date April 26, 2013, 12:14 p.m.
Message ID <517A6F98.2010703@oracle.com>
Download mbox | patch
Permalink /patch/239835/
State New
Headers show

Comments

Paolo Carlini - April 26, 2013, 12:14 p.m.
Hi,

tested x86_64-linux, committed to mainline.

Thanks,
Paolo.

//////////////
2013-04-26  Paolo Carlini  <paolo.carlini@oracle.com>

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

Patch

Index: g++.dg/cpp0x/constexpr-55708.C
===================================================================
--- g++.dg/cpp0x/constexpr-55708.C	(revision 0)
+++ g++.dg/cpp0x/constexpr-55708.C	(working copy)
@@ -0,0 +1,30 @@ 
+// PR c++/55708
+// { dg-do compile { target c++11 } }
+
+template<int N,int NNN>
+struct AA { static constexpr int val = N; };
+
+template<typename A,typename B>
+//constexpr unsigned long long mymax(A a,B b){ // <-- compiles 
+constexpr unsigned long long mymax(A && a,const B& b){
+  return a<b?b:a;
+}
+
+template<char... List>
+constexpr long long operator"" _y() noexcept
+{
+  return AA<1, mymax(1,2)>::val; // <-- crashes gcc
+  // return mymax(1,2);   // <-- compiles
+  // return AA<1,2>::val; // <-- compiles
+}
+
+template<char... List>
+constexpr unsigned long long do_y() noexcept
+{
+  return AA<1, mymax(1,2)>::val; // <-- crashes gcc
+}
+
+int main()
+{
+  return 1_y + do_y();
+}