Skip to content

section type conflict with clang, not with gcc #48040

@llvmbot

Description

@llvmbot
Bugzilla Link 48696
Version trunk
OS Linux
Attachments code to reproduce.
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid,@whisperity

Extended Description

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions