public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56220] New: g++ failed to initialize a __thread local bool variable.
@ 2013-02-06  8:50 gccbug at xiahaiqu dot com
  2013-02-06  9:02 ` [Bug c++/56220] " schwab@linux-m68k.org
  0 siblings, 1 reply; 2+ messages in thread
From: gccbug at xiahaiqu dot com @ 2013-02-06  8:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56220

             Bug #: 56220
           Summary: g++ failed to initialize a __thread local bool
                    variable.
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gccbug@xiahaiqu.com


c++ front end failed to initialize a "__thread" local "bool" variable with
value "true" in a multi-threaded environment. I also did more tests, it could
initialize the variable to "false" correctly. Also it could initialize an "int"
variable correctly.

The bug would also be reproduced with both driver "gcc" and "g++":

witch@desktop:/tmp$ g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

witch@desktop:/tmp$ cat t.cpp
#include <stdio.h>
#include <pthread.h>

void g(bool x) {
    printf("%d\n", x);
}

void* f(void* arg) {
    static __thread bool i = true;
    g(i);
    return NULL;
}

int main() {
    pthread_t a, b;
    pthread_create(&a, NULL, &f, NULL);
    pthread_create(&b, NULL, &f, NULL);
    pthread_join(a, NULL);
    pthread_join(b, NULL);
    return 0;
}
witch@desktop:/tmp$ g++ t.cpp -O2 -pthread
witch@desktop:/tmp$ ./a.out 
1
1
witch@desktop:/tmp$ g++ t.cpp -O0 -pthread
witch@desktop:/tmp$ ./a.out 
0
0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/56220] g++ failed to initialize a __thread local bool variable.
  2013-02-06  8:50 [Bug c++/56220] New: g++ failed to initialize a __thread local bool variable gccbug at xiahaiqu dot com
@ 2013-02-06  9:02 ` schwab@linux-m68k.org
  0 siblings, 0 replies; 2+ messages in thread
From: schwab@linux-m68k.org @ 2013-02-06  9:02 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56220

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |MOVED

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2013-02-06 09:02:27 UTC ---
This is glibc bug 14898 <http://sourceware.org/bugzilla/show_bug.cgi?id=14898>,
fixed in glibc 2.17.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-06  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06  8:50 [Bug c++/56220] New: g++ failed to initialize a __thread local bool variable gccbug at xiahaiqu dot com
2013-02-06  9:02 ` [Bug c++/56220] " schwab@linux-m68k.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).