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
* [Bug libstdc++/98605] clang-tidy error parsing <mutex> on libstdc++-v3
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 ` redi at gcc dot gnu.org
2021-01-09 15:37 ` mizvekov at gmail dot com
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-09 14:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Last reconfirmed| |2021-01-09
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] clang-tidy error parsing <mutex> on libstdc++-v3
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
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mizvekov at gmail dot com @ 2021-01-09 15:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #1 from Matheus Izvekov <mizvekov at gmail dot com> ---
By the way, FYII it is also possible to suppress clang-tidy specific
diagnostics on specific lines with a "comment pragma", like so (untested):
// NOLINT(bugprone-dangling-handle)
// NOLINTNEXTLINE(bugprone-dangling-handle)
This might be better than having the linter parse different code than the real
compiler, while avoiding these kinds of problems where its hard to test every
define combination.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] clang-tidy error parsing <mutex> on libstdc++-v3
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
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-09 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, that seems preferable, thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (2 preceding siblings ...)
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
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-12 15:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Matheus Izvekov from comment #0)
> This was caused by the following commit:
>
> ```
> commit 018813c8994b7dceab1b7d999e9c09654a22ef50
I can't identify that commit. The one in the GCC tree is:
Author: Jonathan Wakely <jwakely@redhat.com>
AuthorDate: Fri Oct 13 13:39:24 2017
PR libstdc++/82481 Suppress clang-tidy warnings
PR libstdc++/82481
* include/std/mutex (call_once): Suppress clang-tidy warnings about
dangling references.
From-SVN: r253724
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (3 preceding siblings ...)
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
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-12 15:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Doh, I missed out the actual commit hash. It was:
commit d1e85aa999ab87009fa02a5261754fbaa69206f2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (4 preceding siblings ...)
2021-01-12 15:56 ` redi at gcc dot gnu.org
@ 2021-01-12 15:57 ` redi at gcc dot gnu.org
2021-01-12 16:24 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-12 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |8.5
Known to work| |11.0, 7.2.0
Known to fail| |10.2.0, 7.3.0, 8.4.0, 9.3.0
Summary|clang-tidy error parsing |[8/9/10 Regression]
|<mutex> on libstdc++-v3 |clang-tidy error parsing
| |<mutex> on libstdc++-v3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (5 preceding siblings ...)
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
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-12 16:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I can't reproduce the original error reported in PR 82481 anyway. Maybe
clang-tidy got smarter (it doesn't show problems in system headers by default,
which helps).
Maybe we can just remove that code entirely.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (6 preceding siblings ...)
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
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mizvekov at gmail dot com @ 2021-01-12 18:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #6 from Matheus Izvekov <mizvekov at gmail dot com> ---
What clang-tidy version? From the date of the commit, it was probably no older
than 6, probably 4 or 5.
If that is too old and probably considered unsupported, I think that is fine.
But even if in the end it was a false positive, the warning seemed to me to be
of high quality, ie to some standard of coding practice, it would be advised to
document this somewhat subtle assumption. Not sure that applies to libstdc++
standards :)
But if you cannot reproduce the original warning anyway, then I guess it's
better to just remove it than make some change that can't even be tested.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (7 preceding siblings ...)
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
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-12 19:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The original report said it was with 4.0.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (8 preceding siblings ...)
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
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-13 13:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:8d3636923a309074eb19240ebaa30c1a0801eaaf
commit r10-9267-g8d3636923a309074eb19240ebaa30c1a0801eaaf
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 13 11:03:58 2021 +0000
libstdc++: Fix clang analyzer suppression [PR 98605]
The fix for PR libstdc++/82481 should only have applied for targets
where _GLIBCXX_HAVE_TLS is defined. Because it was also done for non-TLS
targets, it isn't possible to use clang's analyzers on non-TLS targets
if the code uses <mutex>. This fixes it by using a NOLINT comment on
the relevant line instead of testing #ifdef __clang_analyzer__ and
compiling different code when analyzing.
I'm not actually able to reproduce the analyzer warning with the tools
from Clang 10.0.1 so I'm not going to try to make the suppression more
specific with NOLINTNEXTLINE(clang-analyzer-code.StackAddressEscape).
libstdc++-v3/ChangeLog:
PR libstdc++/98605
* include/std/mutex (call_once): Use NOLINT to suppress clang
analyzer warnings.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (9 preceding siblings ...)
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
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-13 14:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:4aeae11db66c9bce0aadf447e6ff0776a97bfccf
commit r9-9180-g4aeae11db66c9bce0aadf447e6ff0776a97bfccf
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 13 11:03:58 2021 +0000
libstdc++: Fix clang analyzer suppression [PR 98605]
The fix for PR libstdc++/82481 should only have applied for targets
where _GLIBCXX_HAVE_TLS is defined. Because it was also done for non-TLS
targets, it isn't possible to use clang's analyzers on non-TLS targets
if the code uses <mutex>. This fixes it by using a NOLINT comment on
the relevant line instead of testing #ifdef __clang_analyzer__ and
compiling different code when analyzing.
I'm not actually able to reproduce the analyzer warning with the tools
from Clang 10.0.1 so I'm not going to try to make the suppression more
specific with NOLINTNEXTLINE(clang-analyzer-code.StackAddressEscape).
libstdc++-v3/ChangeLog:
PR libstdc++/98605
* include/std/mutex (call_once): Use NOLINT to suppress clang
analyzer warnings.
(cherry picked from commit 8d3636923a309074eb19240ebaa30c1a0801eaaf)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (10 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-13 15:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:283c218a4846075c549f0215d6883e577b26e845
commit r8-10726-g283c218a4846075c549f0215d6883e577b26e845
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 13 11:03:58 2021 +0000
libstdc++: Fix clang analyzer suppression [PR 98605]
The fix for PR libstdc++/82481 should only have applied for targets
where _GLIBCXX_HAVE_TLS is defined. Because it was also done for non-TLS
targets, it isn't possible to use clang's analyzers on non-TLS targets
if the code uses <mutex>. This fixes it by using a NOLINT comment on
the relevant line instead of testing #ifdef __clang_analyzer__ and
compiling different code when analyzing.
I'm not actually able to reproduce the analyzer warning with the tools
from Clang 10.0.1 so I'm not going to try to make the suppression more
specific with NOLINTNEXTLINE(clang-analyzer-code.StackAddressEscape).
libstdc++-v3/ChangeLog:
PR libstdc++/98605
* include/std/mutex (call_once): Use NOLINT to suppress clang
analyzer warnings.
(cherry picked from commit 8d3636923a309074eb19240ebaa30c1a0801eaaf)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (11 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-13 15:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This should be fixed in all active branches now.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/98605] [8/9/10 Regression] clang-tidy error parsing <mutex> on libstdc++-v3
2021-01-08 19:07 [Bug libstdc++/98605] New: clang-tidy error parsing <mutex> on libstdc++-v3 mizvekov at gmail dot com
` (12 preceding siblings ...)
2021-01-13 15:11 ` redi at gcc dot gnu.org
@ 2021-01-13 18:33 ` mizvekov at gmail dot com
13 siblings, 0 replies; 15+ messages in thread
From: mizvekov at gmail dot com @ 2021-01-13 18:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98605
--- Comment #12 from Matheus Izvekov <mizvekov at gmail dot com> ---
Thank you!!!
^ 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).