public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mizvekov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3
Date: Fri, 08 Jan 2021 19:07:42 +0000	[thread overview]
Message-ID: <bug-98605-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98605
           Summary: clang-tidy error parsing <mutex> on libstdc++-v3
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mizvekov at gmail dot com
  Target Milestone: ---

clang-tidy errors parsing `#include <mutex>` when _GLIBCXX_HAVE_TLS is not
defined, with the following message:
```
include/c++/mutex:738:7: error: use of undeclared identifier '__once_callable';
did you mean '__callable'? [clang-diagnostic-error]
      __once_callable = nullptr;
      ^
include/c++/mutex:716:12: note: '__callable' declared here
      auto __callable = [&] {
           ^
include/c++/mutex:739:7: error: use of undeclared identifier '__once_call'
[clang-diagnostic-error]
      __once_call = nullptr;
      ^
```

This was caused by the following commit:

```
commit 018813c8994b7dceab1b7d999e9c09654a22ef50
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Oct 13 12:56:07 2017 +0100

    PR libstdc++/82481 Suppress clang-tidy warnings

            PR libstdc++/82481
            * include/std/mutex (call_once): Suppress clang-tidy warnings about
            dangling references.

diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 8c692a88ffd..50420ee22d4 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -688,6 +688,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         __set_once_functor_lock_ptr(0);
 #endif

+#ifdef __clang_analyzer__
+      // PR libstdc++/82481
+      __once_callable = nullptr;
+      __once_call = nullptr;
+#endif
+
       if (__e)
        __throw_system_error(__e);
     }
```

The problem is that __once_callable et al are only declared when
_GLIBCXX_HAVE_TLS is defined.

A simple patch like this would fix it:
```
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -731,9 +731,7 @@
 #ifndef _GLIBCXX_HAVE_TLS
       if (__functor_lock)
         __set_once_functor_lock_ptr(0);
-#endif
-
-#ifdef __clang_analyzer__
+#elif defined(__clang_analyzer__)
       // PR libstdc++/82481
       __once_callable = nullptr;
       __once_call = nullptr;
```

             reply	other threads:[~2021-01-08 19:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 19:07 mizvekov at gmail dot com [this message]
2021-01-09 14:39 ` [Bug libstdc++/98605] " redi at gcc dot gnu.org
2021-01-09 15:37 ` mizvekov at gmail dot com
2021-01-09 15:59 ` redi at gcc dot gnu.org
2021-01-12 15:55 ` redi at gcc dot gnu.org
2021-01-12 15:56 ` redi at gcc dot gnu.org
2021-01-12 15:57 ` [Bug libstdc++/98605] [8/9/10 Regression] " redi at gcc dot gnu.org
2021-01-12 16:24 ` redi at gcc dot gnu.org
2021-01-12 18:52 ` mizvekov at gmail dot com
2021-01-12 19:36 ` redi at gcc dot gnu.org
2021-01-13 13:06 ` cvs-commit at gcc dot gnu.org
2021-01-13 14:14 ` cvs-commit at gcc dot gnu.org
2021-01-13 15:10 ` cvs-commit at gcc dot gnu.org
2021-01-13 15:11 ` redi at gcc dot gnu.org
2021-01-13 18:33 ` mizvekov at gmail dot com

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-98605-4@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).