Package: gcc-14
Version: 14.2.0-19
Severity: normal
X-Debbugs-Cc: fanp...@loongson.cn

Dear Maintainer,

As https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119507 mentioned:

We think this patch should be backported.

-- System Information:
Debian Release: 13.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: loong64 (loongarch64)

Kernel: Linux 6.6.34-9.2.loongarch64 (SMP w/32 CPU threads)
Kernel taint flags: TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages gcc-14 depends on:
ii  binutils                      2.44-3
ii  cpp-14                        14.2.0-19
ii  gcc-14-base                   14.2.0-19
ii  gcc-14-loongarch64-linux-gnu  14.2.0-19

Versions of packages gcc-14 recommends:
ii  libc6-dev  2.41-8

Versions of packages gcc-14 suggests:
pn  gcc-14-doc      <none>
pn  gcc-14-locales  <none>

-- no debconf information
--- a/src/gcc/except.cc
+++ b/src/gcc/except.cc
@@ -2906,7 +2906,14 @@ switch_to_exception_section (const char * ARG_UNUSED 
(fnname))
 {
   section *s;
 
-  if (exception_section)
+  if (exception_section
+  /* Don't use the cached section for comdat if it will be different. */
+#ifdef HAVE_LD_EH_GC_SECTIONS
+      && !(targetm_common.have_named_sections
+          && DECL_COMDAT_GROUP (current_function_decl)
+          && HAVE_COMDAT_GROUP)
+#endif
+     )
     s = exception_section;
   else
     {
--- /dev/null
+++ b/src/gcc/testsuite/g++.dg/eh/pr119507.C
@@ -0,0 +1,17 @@
+// { dg-do compile { target comdat_group } }
+// Force off function sections
+// Force on exceptions
+// { dg-options "-fno-function-sections -fexceptions" }
+// PR middle-end/119507
+
+
+inline int comdat() { try { throw 1; } catch (int) { return 1; } return 0; }
+int another_func_with_exception() { try { throw 1; } catch (int) { return 1; } 
return 0; }
+inline int comdat1() { try { throw 1; } catch (int) { return 1; } return 0; }
+int foo() { return comdat() + comdat1(); }
+
+// Make sure the gcc puts the exception table for both comdat and comdat1 in 
their own section
+// { dg-final { scan-assembler-times ".section\[\t 
\]\[^\n\]*.gcc_except_table._Z6comdatv" 1 } }
+// { dg-final { scan-assembler-times ".section\[\t 
\]\[^\n\]*.gcc_except_table._Z7comdat1v" 1 } }
+// There should be 3 exception tables, 
+// { dg-final { scan-assembler-times ".section\[\t 
\]\[^\n\]*.gcc_except_table" 3 } }

Reply via email to