]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/55708 (g++ crashes: constexpr function with reference parameters.)
authorPaolo Carlini <paolo@gcc.gnu.org>
Fri, 26 Apr 2013 12:11:14 +0000 (12:11 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 26 Apr 2013 12:11:14 +0000 (12:11 +0000)
2013-04-26  Paolo Carlini  <paolo.carlini@oracle.com>

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

From-SVN: r198337

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C [new file with mode: 0644]

index 737ef4a926f4eff758386bcfd6e8c2c51f927291..1081ef992519b58d0ca8b8cdb167544b9e7aaf1b 100644 (file)
@@ -1,4 +1,9 @@
-2013-03-26  Richard Biener  <rguenther@suse.de>
+2013-04-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55708
+       * g++.dg/cpp0x/constexpr-55708.C: New.
+
+2013-04-26  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/tree-prof/update-loopch.c: Revert last change.
        * gcc.dg/graphite/pr33766.c: Fix undefined behavior.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C
new file mode 100644 (file)
index 0000000..ffbefbb
--- /dev/null
@@ -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();
+}
This page took 0.06635 seconds and 5 git commands to generate.