public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103937] New: Assembler error: symbol is already defined when compiling static member function templates
@ 2022-01-07  8:44 mac.zyg2 at protonmail dot com
  2022-01-07  8:44 ` [Bug c++/103937] " mac.zyg2 at protonmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mac.zyg2 at protonmail dot com @ 2022-01-07  8:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103937

            Bug ID: 103937
           Summary: Assembler error: symbol is already defined when
                    compiling static member function templates
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mac.zyg2 at protonmail dot com
  Target Milestone: ---

Created attachment 52139
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52139&action=edit
Full error message for GCC 11.2

This code doesn't compile with "symbol ... is already defined":
```
class SortAlgorithm {
public:
    template<typename T>
    static void test(T* t, bool(*compare_func)() = 
                    []() -> bool { return true; }) {
        test(t);
    }
};

int main() {
    int arr[] { 1, 2 };
    SortAlgorithm::test(arr);
}
```

The names that are included in the error demangles to this:

```
>>> demangle('_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NKUlvE_clEv')
'SortAlgorithm::test<int>(int*, bool (*)())::{default
arg#1}::{lambda()#1}::operator()() const'
>>> demangle('_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NUlvE_4_FUNEv')
'SortAlgorithm::test<int>(int*, bool (*)())::{default
arg#1}::{lambda()#1}::_FUN()'
>>> demangle('_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NKUlvE_cvS4_Ev')
'SortAlgorithm::test<int>(int*, bool (*)())::{default
arg#1}::{lambda()#1}::operator bool (*)()() const'
```

This code throws internal compiler error on trunk:

```
<source>:13:1: error: Two symbols with same comdat_group are not linked by the
same_comdat_group list.
   13 | }
      | ^
_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NKUlvE_cvS4_Ev/6 (constexpr
SortAlgorithm::<lambda()>::operator bool (*)()() const) @0x7f86cadb8880
  Type: function definition analyzed
  Visibility: semantic_interposition no_reorder public weak comdat
comdat_group:_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NKUlvE_cvS4_Ev one_only
artificial
  previous sharing asm name: 2
  References: _ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NUlvE_4_FUNEv/5 (addr)
__gxx_personality_v0/8 (addr) 
  Referring: 
  Function flags: body
  Called by: _ZN13SortAlgorithm4testIiEEvPT_PFbvE/7 
  Calls: 
_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NKUlvE_cvS4_Ev/2 (constexpr
SortAlgorithm::<lambda()>::operator bool (*)()() const) @0x7f86cadb8440
  Type: function definition analyzed
  Visibility: semantic_interposition no_reorder public weak comdat
comdat_group:_ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NKUlvE_cvS4_Ev one_only
artificial
  next sharing asm name: 6
  References: _ZZN13SortAlgorithm4testIiEEvPT_PFbvEEd_NUlvE_4_FUNEv/1 (addr)
__gxx_personality_v0/8 (addr) 
  Referring: 
  Function flags: body
  Called by: main/3 
  Calls: 
<source>:13:1: internal compiler error: symtab_node::verify failed
0x213d2c9 internal_error(char const*, ...)
        ???:0
0xbd4532 symtab_node::verify_symtab_nodes()
        ???:0
0xbf0a6f symbol_table::finalize_compilation_unit()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

Demo: https://godbolt.org/z/G796Wxehb

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-07  8:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  8:44 [Bug c++/103937] New: Assembler error: symbol is already defined when compiling static member function templates mac.zyg2 at protonmail dot com
2022-01-07  8:44 ` [Bug c++/103937] " mac.zyg2 at protonmail dot com
2022-01-07  8:47 ` [Bug c++/103937] [11/12 Regression] Assembler error: symbol is already defined when compiling static member function templates since r11-7965-g23be03a0f243a084 marxin at gcc dot gnu.org
2022-01-07  8:49 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).