* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
@ 2024-04-18 17:14 ` pinskia at gcc dot gnu.org
2024-04-18 18:09 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-18 17:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
EDG also accepts it ...
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
2024-04-18 17:14 ` [Bug c++/114764] " pinskia at gcc dot gnu.org
@ 2024-04-18 18:09 ` mpolacek at gcc dot gnu.org
2024-04-18 18:24 ` dangelog at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-04-18 18:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think I remember discussing this on the Core list. IIRC the trouble was that
friend decls can be redeclared and that made it quite hard to implement right.
So the current behavior seems OK, and perhaps the standard should change.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
2024-04-18 17:14 ` [Bug c++/114764] " pinskia at gcc dot gnu.org
2024-04-18 18:09 ` mpolacek at gcc dot gnu.org
@ 2024-04-18 18:24 ` dangelog at gmail dot com
2024-04-18 19:53 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dangelog at gmail dot com @ 2024-04-18 18:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
--- Comment #3 from Giuseppe D'Angelo <dangelog at gmail dot com> ---
I guess you're referring to https://lists.isocpp.org/core/2019/07/6785.php ?
I'm really not sure why a friend function declaration is different from a free
function, where multiple equivalent declarations are allowed?
Btw, the "real" case was a definition of a friend (hidden friend). Could at
least that be supported?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
` (2 preceding siblings ...)
2024-04-18 18:24 ` dangelog at gmail dot com
@ 2024-04-18 19:53 ` mpolacek at gcc dot gnu.org
2024-04-19 8:51 ` dangelog at gmail dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-04-18 19:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I don't think so, it's the same problem. You could have
struct S {
friend void f() noexcept(noexcept(a));
friend void f() noexcept(noexcept(b)) { }
int a;
int b;
};
and we'd have to track if the exception specifications match.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
` (3 preceding siblings ...)
2024-04-18 19:53 ` mpolacek at gcc dot gnu.org
@ 2024-04-19 8:51 ` dangelog at gmail dot com
2024-04-19 15:49 ` mpolacek at gcc dot gnu.org
2024-04-20 11:30 ` dangelog at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: dangelog at gmail dot com @ 2024-04-19 8:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
--- Comment #5 from Giuseppe D'Angelo <dangelog at gmail dot com> ---
Just to understand, are we talking about an implementation challenge (because
within a class you may refer to stuff not yet declared when parsing the
noexcept spec, or similar), or that using noexcept on a friend "doesn't make
sense"?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
` (4 preceding siblings ...)
2024-04-19 8:51 ` dangelog at gmail dot com
@ 2024-04-19 15:49 ` mpolacek at gcc dot gnu.org
2024-04-20 11:30 ` dangelog at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-04-19 15:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The former: I'd have to introduce checking that tracks all the declarations and
checks that their noexcept-specs match after delayed parsing has taken place.
It's not impossible but I didn't (and still don't) think that it's something
worth doing. Sorry.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114764] noexcept on a friend complains about incomplete type
2024-04-18 9:21 [Bug c++/114764] New: noexcept on a friend complains about incomplete type dangelog at gmail dot com
` (5 preceding siblings ...)
2024-04-19 15:49 ` mpolacek at gcc dot gnu.org
@ 2024-04-20 11:30 ` dangelog at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: dangelog at gmail dot com @ 2024-04-20 11:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114764
--- Comment #7 from Giuseppe D'Angelo <dangelog at gmail dot com> ---
I get it :)
If you wanted an actual use-case (rather than a synthetic testcase), we
stumbled upon this bug from implementing a friend operator==:
```
class S {
bool comparesEqual(S, S) noexcept; // pass by value, object is
small/trivially copyable
friend inline bool operator==(S a, S b) noexcept(noexcept(comparesEqual(S,
S))) {
returns comparesEqual(a, b);
}
};
```
which is the result of some macro expansions through which we support C++20's
comparisons in C++17 in Qt. The problem is the pass by value -- changing it to
pass by const-ref fixes it, but generates different linting about not passing a
small TC object by value...
^ permalink raw reply [flat|nested] 8+ messages in thread