public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-21 16:48 ` martin.ankerl at gmail dot com
2021-04-21 20:35 ` msebor at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: martin.ankerl at gmail dot com @ 2021-04-21 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
Martin Ankerl <martin.ankerl at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |martin.ankerl at gmail dot com
--- Comment #1 from Martin Ankerl <martin.ankerl at gmail dot com> ---
I just "discovered" this bug as well. The warning works correctly in g++ 6.4,
but starting from 7.1 upwards it does not work any more.
My reproducer which is very similar:
struct Foo {
[[nodiscard]] virtual bool foo() { return true; };
virtual ~Foo() = default;
};
void shouldEmitWarning() {
auto* f = new Foo();
f->foo(); // <-- why no warning here?
delete f;
}
Godbolt link: https://godbolt.org/z/xqaPrshYn
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
2021-04-21 16:48 ` [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer martin.ankerl at gmail dot com
@ 2021-04-21 20:35 ` msebor at gcc dot gnu.org
2021-06-02 10:29 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-21 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |10.2.0, 11.0, 8.3.0, 9.2.0
Ever confirmed|0 |1
CC| |msebor at gcc dot gnu.org
Last reconfirmed| |2021-04-21
Status|UNCONFIRMED |NEW
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed with GCC 11 and test case in comment #1. Attribute
warn_unused_result does the right thing here.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
2021-04-21 16:48 ` [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer martin.ankerl at gmail dot com
2021-04-21 20:35 ` msebor at gcc dot gnu.org
@ 2021-06-02 10:29 ` redi at gcc dot gnu.org
2021-06-02 10:32 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-02 10:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Ankerl from comment #1)
> I just "discovered" this bug as well. The warning works correctly in g++
> 6.4, but starting from 7.1 upwards it does not work any more.
No, I don't think that's true, this never worked. The warning for gcc 6 is
telling you that it doesn't understand the [[nodiscard]] attribute. You would
get the same warning for [[lolwut]].
GCC 7 does understand the attribute, so that -Wattributes warning is gone, but
the expected warning about the unused result is missing.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2021-06-02 10:29 ` redi at gcc dot gnu.org
@ 2021-06-02 10:32 ` redi at gcc dot gnu.org
2021-06-02 10:33 ` redi at gcc dot gnu.org
2021-06-04 23:28 ` msebor at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-02 10:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pacoarjonilla at yahoo dot es
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 97712 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-06-02 10:32 ` redi at gcc dot gnu.org
@ 2021-06-02 10:33 ` redi at gcc dot gnu.org
2021-06-04 23:28 ` msebor at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-02 10:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2021-04-21 00:00:00 |2021-6-2
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In PR 97712 Jakub said:
[[nodiscard]] is a function attribute rather than function type attribute, so
it really doesn't apply to virtual calls (unless it can be devirtualized
early).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2021-06-02 10:33 ` redi at gcc dot gnu.org
@ 2021-06-04 23:28 ` msebor at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-06-04 23:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
The same problem applies to attribute noreturn (but not deprecated). Clang,
ICC, and Visual C++ behave as expected in both cases, suggesting GCC should
change.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-04 23:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-84476-4@http.gcc.gnu.org/bugzilla/>
2021-04-21 16:48 ` [Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer martin.ankerl at gmail dot com
2021-04-21 20:35 ` msebor at gcc dot gnu.org
2021-06-02 10:29 ` redi at gcc dot gnu.org
2021-06-02 10:32 ` redi at gcc dot gnu.org
2021-06-02 10:33 ` redi at gcc dot gnu.org
2021-06-04 23:28 ` msebor at gcc dot gnu.org
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).