https://bugs.llvm.org/show_bug.cgi?id=48696

            Bug ID: 48696
           Summary: section type conflict with clang, not with gcc
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: balazs.samu.fek...@ericsson.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Created attachment 24365
  --> https://bugs.llvm.org/attachment.cgi?id=24365&action=edit
code to reproduce.

We ran into an issue when adding a section attribute for certain symbols:

[[gnu::section(".bss")]] const int Stuff::xi = rand();
[[gnu::section(".bss")]] std::tr1::unordered_map<int,int> uom;

Full example code attached.

error I get when compiling:

$ clang++ -O2 -pipe -g -fno-omit-frame-pointer -std=c++11 main.cc stuff.cc
stuff.cc:8:59: error: 'uom' causes a section type conflict with 'xi'
[[gnu::section(".bss")]] std::tr1::unordered_map<int,int> uom;
                                                          ^
stuff.cc:6:43: note: declared here
[[gnu::section(".bss")]] const int Stuff::xi = rand();
                                          ^
1 error generated.

Compiled without the section attributes result is that they are both put in
.bss, but when explicitly defining them, clang++ throws a section type
conflict.

Tried both with llvm 8.0 and 12.0. Also tried with
-fno-zero-initialized-in-bss, in that case they were put in .data, but I got
the same error when I added the attribute.

The same code compiles and runs with g++ (tried with versions 5.4.0 and 7.5.0).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to