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)

Reply via email to