This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81915] New: bug with thread_local inline variables


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81915

            Bug ID: 81915
           Summary: bug with thread_local inline variables
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nico at josuttis dot de
  Target Milestone: ---

Consider:

inlinetls.hpp:
  #include <string>
  inline thread_local std::string tlsString = "hello";

inlinetls1.cpp:
  #include "inlinetls.hpp"
  int main()
  {
  }

inlinetls2.cpp:
  #include "inlinetls.hpp"

IMO, this is valid code since C++17 having a thread-local tlsString.

But I get:
> /cygdrive/p/gcc/gcc72/bin/g++72 --std=c++17 -O2 --pedantic --pedantic-errors -Wall -Wextra -Wnon-virtual-dtor -Wconversion inlinetls1.cpp inlinetls2.cpp -latomic -o inlinetlsraw17.exe
> /cygdrive/c/Users/nico/AppData/Local/Temp/ccyiFSQ3.o:inlinetls2.cpp:(.text+0x0): multiple definition of `TLS init function for tlsString[abi:cxx11]'
> /cygdrive/c/Users/nico/AppData/Local/Temp/cc5mSIJv.o:inlinetls1.cpp:(.text+0x0): first defined here
> collect2: error: ld returned 1 exit status

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]