This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41091] Using section attribute in c and c++ function causes section type conflict
- From: "erenon2 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Oct 2017 22:18:46 +0000
- Subject: [Bug c++/41091] Using section attribute in c and c++ function causes section type conflict
- Auto-submitted: auto-generated
- References: <bug-41091-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41091
Benedek <erenon2 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |erenon2 at gmail dot com
--- Comment #6 from Benedek <erenon2 at gmail dot com> ---
The following code reproduces this, or a very similar issue:
#define STORE(SECTION, STRING) \
__attribute__((section(SECTION), used)) \
static constexpr const char* s[] = { STRING }
void f()
{
STORE(".custom", "normal_foobar");
}
inline void g()
{
STORE(".custom", "inline_foobar");
}
template <typename = void>
void h()
{
STORE(".custom", "template_foobar");
}
int main()
{
f(); g(); h();
return 0;
}
$ g++ -std=c++11 section.cpp
section.cpp: error: 's' causes a section type conflict with 's'
GCC 4.8, 5.2, 7.2, and trunk are affected (x86-64, checked on godbolt).
Depending on the compiler version, either the normal and the inline, or the
normal and the function template clashes.
I suppose because of how comdat is handled, they might have slightly different
needs, but it would be really nice to make it easier for the user.
(Clang compiles it fine)