diff mbox

PR lto/65276 remove odr_violated assert

Message ID 54F4AF39.6030402@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez March 2, 2015, 6:43 p.m. UTC
TYPE_BINFO is null when no optimization is used, but odr_violated is unset.

Fixed and approved in the PR by Honza.

Tested on x86-64 Linux.

Committed to mainline.
commit a26ff3a2376a898bef8ca8ab17a457052d677a62
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Mar 2 09:55:28 2015 -0800

    	PR lto/65276
    	* ipa-devirt.c (add_type_duplicate): Remove odr_violated assert
    	when checking TYPE_BINFO.

Comments

Alex Velenko March 17, 2015, 3:10 p.m. UTC | #1
On 02/03/15 18:43, Aldy Hernandez wrote:
> TYPE_BINFO is null when no optimization is used, but odr_violated is unset.
>
> Fixed and approved in the PR by Honza.
>
> Tested on x86-64 Linux.
>
> Committed to mainline.
>

Hi,
I believe your testcase does not work for arm-none-eabi:

Executing on host: /arm-none-eabi/obj/gcc2/gcc/testsuite/g++8/../../xg++ 
-B/arm-none-eabi/obj/gcc2/gcc/testsuite/g++8/../../ cp_lto_pr65276_0.o 
cp_lto_pr65276_1.o g++_tg.o  -fno-diagnostics-show-caret 
-fdiagnostics-color=never  -nostdinc++ 
-I/arm-none-eabi/obj/gcc2/arm-none-eabi/libstdc++-v3/include/arm-none-eabi 
-I/arm-none-eabi/obj/gcc2/arm-none-eabi/libstdc++-v3/include 
-I/src/gcc/libstdc++-v3/libsupc++ 
-I/src/gcc/libstdc++-v3/include/backward 
-I/src/gcc/libstdc++-v3/testsuite/util -fmessage-length=0 -flto -O0 
-std=c++11   -specs=rdimon.specs -Wa,-mno-warn-deprecated 
-L/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs 
-B/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs 
-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort      -o 
g++-dg-lto-pr65276-01.exe    (timeout = 300)
spawn /arm-none-eabi/obj/gcc2/gcc/testsuite/g++8/../../xg++ 
-B/arm-none-eabi/obj/gcc2/gcc/testsuite/g++8/../../ cp_lto_pr65276_0.o 
cp_lto_pr65276_1.o g++_tg.o -fno-diagnostics-show-caret 
-fdiagnostics-color=never -nostdinc++ 
-I/arm-none-eabi/obj/gcc2/arm-none-eabi/libstdc++-v3/include/arm-none-eabi 
-I/arm-none-eabi/obj/gcc2/arm-none-eabi/libstdc++-v3/include 
-I/src/gcc/libstdc++-v3/libsupc++ 
-I/src/gcc/libstdc++-v3/include/backward 
-I/src/gcc/libstdc++-v3/testsuite/util -fmessage-length=0 -flto -O0 
-std=c++11 -specs=rdimon.specs -Wa,-mno-warn-deprecated 
-L/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs 
-B/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs 
-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -o 
g++-dg-lto-pr65276-01.exe
/tmp/61243907.0/ccwrV09Z.ltrans0.ltrans.o:(.rodata+0x0): multiple 
definition of `typeinfo for std::exception'
/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs/libstdc++.a(eh_exception.o):(.rodata._ZTISt9exception+0x0): 
first defined here
/tmp/61243907.0/ccwrV09Z.ltrans0.ltrans.o:(.rodata+0x8): multiple 
definition of `typeinfo name for std::exception'
/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs/libstdc++.a(eh_exception.o):/src/gcc/libstdc++-v3/libsupc++/eh_exception.cc:35: 
first defined here
collect2: error: ld returned 1 exit status
compiler exited with status 1
output is:
/tmp/61243907.0/ccwrV09Z.ltrans0.ltrans.o:(.rodata+0x0): multiple 
definition of `typeinfo for std::exception'
/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs/libstdc++.a(eh_exception.o):(.rodata._ZTISt9exception+0x0): 
first defined here
/tmp/61243907.0/ccwrV09Z.ltrans0.ltrans.o:(.rodata+0x8): multiple 
definition of `typeinfo name for std::exception'
/arm-none-eabi/obj/gcc2/arm-none-eabi/./libstdc++-v3/src/.libs/libstdc++.a(eh_exception.o):/src/gcc/libstdc++-v3/libsupc++/eh_exception.cc:35: 
first defined here
collect2: error: ld returned 1 exit status

FAIL: g++.dg/lto/pr65276 cp_lto_pr65276_0.o-cp_lto_pr65276_1.o link, 
-flto -O0 -std=c++11
UNRESOLVED: g++.dg/lto/pr65276 cp_lto_pr65276_0.o-cp_lto_pr65276_1.o 
execute -flto -O0 -std=c++11

Kind regards,
Alex
diff mbox

Patch

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index c3f8b15..fe29932 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1459,7 +1459,6 @@  add_type_duplicate (odr_type val, tree type)
 			&& polymorphic_type_binfo_p (TYPE_BINFO (type1))
 		           != polymorphic_type_binfo_p (TYPE_BINFO (type2))))
 		  {
-		    gcc_assert (val->odr_violated);
 		    base_mismatch = true;
 		    break;
 		  }
diff --git a/gcc/testsuite/g++.dg/lto/pr65276_0.C b/gcc/testsuite/g++.dg/lto/pr65276_0.C
new file mode 100644
index 0000000..c8e9699
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr65276_0.C
@@ -0,0 +1,61 @@ 
+// { dg-lto-do link }
+// { dg-lto-options {{-flto -O0 -std=c++11}} }
+
+/* pr65276_0.C should get compiled with -O0, while the _1.C file
+   should get compiled with -O2, and the entire thing should be linked
+   with -O0.  Test that we don't get an ICE.  */
+
+extern "C++"
+{
+  namespace std
+  {
+    class exception
+    {
+    public:
+      virtual ~ exception () noexcept;
+    };
+  }
+}
+namespace std
+{
+  struct __cow_string
+  {
+    union
+    {
+      const char *_M_p;
+      char _M_bytes[sizeof (const char *)];
+    };
+  };
+  class runtime_error:public exception
+  {
+    __cow_string _M_msg;
+  };
+}
+namespace std
+{
+  class system_error:public std::runtime_error
+  {
+  };
+  enum _Ios_Fmtflags
+  {
+  };
+  inline constexpr _Ios_Fmtflags operator& (_Ios_Fmtflags __a,
+                                            _Ios_Fmtflags __b)
+  {
+    return _Ios_Fmtflags ();
+  }
+  enum _Ios_Openmode
+  {
+  };
+  class ios_base
+  {
+  public:
+    class __attribute ((__abi_tag__ ("cxx11"))) failure:public system_error
+    {
+    };
+    class Init
+    {
+    };
+  };
+  static ios_base::Init __ioinit;
+}
diff --git a/gcc/testsuite/g++.dg/lto/pr65276_1.C b/gcc/testsuite/g++.dg/lto/pr65276_1.C
new file mode 100644
index 0000000..ee49752
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr65276_1.C
@@ -0,0 +1,34 @@ 
+// { dg-options "-O2" }
+#pragma implementation
+#pragma interface
+extern "C++"
+{
+  namespace std
+  {
+    class exception
+    {
+    public:
+      virtual ~ exception () noexcept;
+    };
+  }
+}
+namespace std
+{
+  struct __cow_string
+  {
+    union
+    {
+      const char *_M_p;
+      char _M_bytes[sizeof (const char *)];
+    };
+  };
+  class runtime_error:public exception
+  {
+    __cow_string _M_msg;
+  };
+}
+
+int main()
+{
+  return 0;
+}