[llvm-bugs] [Bug 48696] New: section type conflict with clang, not with gcc

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 8 00:09:48 PST 2021


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: unassignedclangbugs at nondot.org
          Reporter: balazs.samu.fekete at ericsson.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210108/988689bf/attachment.html>


More information about the llvm-bugs mailing list