public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60673] c++11 static thread_local members may cause a segfault when accessed via 'this->'
Date: Sun, 22 Aug 2021 22:46:42 +0000	[thread overview]
Message-ID: <bug-60673-4-fEmbsCNXEZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60673-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> This seems to be fixed in GCC 5 onwards (and recent Clang versions).

It was not fixed until GCC 7.5, 8.4 and 9+.
Here is a reduced testcase which shows it was not fixed until then:
extern "C" void abort(void);
struct tt
{
  int *tt1 = new int{1};
  int bucket_count() const {return *tt1;}
};
struct A{
        static thread_local tt  s;

        int f() {
                return this->s.bucket_count();
        }
        int g() {
                return A::s.bucket_count();
        }
        int h() {
                return s.bucket_count();
        }
};
thread_local tt A::s;
int main() {
        if (A{}.f() != 1) abort();
        return 0;
}

  parent reply	other threads:[~2021-08-22 22:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-26 16:47 [Bug c++/60673] New: " michael at ensslin dot cc
2014-03-26 18:44 ` [Bug c++/60673] " redi at gcc dot gnu.org
2021-08-22 22:46 ` pinskia at gcc dot gnu.org [this message]
2021-08-22 22:48 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60673-4-fEmbsCNXEZ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).