public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3
@ 2021-01-08 19:07 mizvekov at gmail dot com
  2021-01-09 14:39 ` [Bug libstdc++/98605] " redi at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: mizvekov at gmail dot com @ 2021-01-08 19:07 UTC (permalink / raw)
  To: gcc-bugs

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;
```

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

end of thread, other threads:[~2021-01-13 18:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
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

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).