#327 __declspec(thread) results in a warning instead of error

closed-invalid
nobody
None
5
2012-11-28
2012-11-28
No

The configure script from http://pixman.org library tries to check whether to use __thread or __declspec(thread) for TLS by compiling a small test program (basically a single line "int __declspec(thread) x;") and checking whether the compiler accepts it. The result with mingw-w64 is the following:

configure:13768: x86_64-w64-mingw32-gcc -c -g -O2 -Wall -fno-strict-aliasing conftest.c >&5
conftest.c:40:1: warning: 'thread' attribute directive ignored
configure:13768: $? = 0
configure:13776: result: __declspec(thread)

Because __declspec(thread) results in just a warning and not a compilation failure, the configure script thinks that __declspec(thread) is supported and happens to select it. You can find more details at https://bugs.freedesktop.org/show_bug.cgi?id=57591

Would it possible to promote this from a warning to an error? Or just alias __declspec(thread) to __thread? The current behaviour can be workarounded by changing the order of checks for __thread and __declspec(thread), but it is fragile and leaves little safety margin. Just imagine some other compiler doing something similar with the __thread keyword and we are in a real trouble.

Discussion

  • Ozkan Sezer

    Ozkan Sezer - 2012-11-28

    This is not a mingw-w64 bug: That gcc only emitting a warning is a known behavior on gcc side, therefore the pixman configury must handle the situation properly by temporarily adding -Werror to its CPPFLAGS. In other words, this seems like a pixman bug. Closing as invalid.

     
  • Ozkan Sezer

    Ozkan Sezer - 2012-11-28
    • status: open --> closed-invalid
     
  • Siarhei Siamashka

    Do you mean I need to report this bug to upstream gcc?

     
  • Siarhei Siamashka

    • status: closed-invalid --> open-invalid
     
  • Ozkan Sezer

    Ozkan Sezer - 2012-11-28
    • status: open-invalid --> closed-invalid
     
  • Ozkan Sezer

    Ozkan Sezer - 2012-11-28

    No: gcc always emits a warning for unrecognized attributes, and for mingw[-w64] cases __declspec is defined as __attribute__. This is a pixman.org bug and it needs to be reported to pixman.org developers.

     
  • Siarhei Siamashka

    The pixman bug (there is a link in my original report) has explanations why -Werror is not a very nice solution and has some implications. Anyway, thanks for explaining the __declspec to __attribute__ mapping details. So this braindead handling of unrecognized attributes is the thing that comes from the upstream gcc and mingw-w64 has nothing to do with it. This was not entirely clear for me from the start because normal linux gcc compiler is just failing on __declspec(thread), but now it makes sense. Thanks again.

     
  • Siarhei Siamashka

    • status: closed-invalid --> open-invalid
     
  • Ozkan Sezer

    Ozkan Sezer - 2012-11-28
    • status: open-invalid --> closed-invalid
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks