public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14
@ 2023-10-30 13:51 arkamar at atlas dot cz
2023-10-30 14:09 ` [Bug c++/112293] " redi at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: arkamar at atlas dot cz @ 2023-10-30 13:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
Bug ID: 112293
Summary: Enhance error reporting with fix-it for missing
<algorithm> in gcc 14
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: arkamar at atlas dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
We encountered an issue while attempting to build the rspamd package using
gcc-14 on Gentoo Linux. The build process fails with a somewhat ambiguous error
message [1]. However, the same package compiles successfully with gcc-13.
The issue appears to arise from internal changes in libstdc++ that now require
the explicit inclusion of the <algorithm> header (this part is likely a bug
within rspamd). Is it possible to enhance the error messaging, perhaps with a
fix-it hint, to suggest that <algorithm> needs to be explicitly included for
clarity?
Here is the minimized snippet to reproduce the issue:
#include <functional>
#include <stdexcept>
struct test;
std::vector<test *> v;
auto f(test *t) {
auto it = std::remove(begin(v), end(v), t);
}
which currently fails with the following error message:
test.cxx: In function _auto f(test*)_:
test.cxx:6:30: error: cannot convert _std::vector<test*>::iterator_ to _const
char*_
6 | auto it = std::remove(begin(v), end(v), t);
| ~~~~~^~~
| |
| std::vector<test*>::iterator
In file included from
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/cstdio:42,
from
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/ext/string_conversions.h:45,
from
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/basic_string.h:4158,
from
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/string:54,
from
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/stdexcept:39,
from test.cxx:2:
/usr/include/stdio.h:157:32: note: initializing argument 1 of _int
remove(const char*)_
157 | extern int remove (const char *__filename) __THROW;
|
I tested this with: gcc version 14.0.0 20231022 (experimental) (Gentoo
14.0.0_pre20231022-r1 p7)
[1] https://bugs.gentoo.org/916438
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
@ 2023-10-30 14:09 ` redi at gcc dot gnu.org
2023-10-30 14:11 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-30 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Petr Vaněk from comment #0)
> The issue appears to arise from internal changes in libstdc++ that now
> require the explicit inclusion of the <algorithm> header (this part is
> likely a bug within rspamd).
The C++ standard always required the explicit inclusion of <algorithm> for the
std::remove algorithm. This is definitely a bug in rspamd.
> Is it possible to enhance the error messaging,
> perhaps with a fix-it hint, to suggest that <algorithm> needs to be
> explicitly included for clarity?
That would be difficult, because std::remove is overloaded and another overload
was found here (the one declared in <cstdio>). Usually we only provide fix-it
hints when name lookup doesn't find anything.
> Here is the minimized snippet to reproduce the issue:
>
> #include <functional>
> #include <stdexcept>
> struct test;
> std::vector<test *> v;
> auto f(test *t) {
> auto it = std::remove(begin(v), end(v), t);
> }
This is broken in two ways, you need to include both <algorithm> *and* <vector>
for this program.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
2023-10-30 14:09 ` [Bug c++/112293] " redi at gcc dot gnu.org
@ 2023-10-30 14:11 ` redi at gcc dot gnu.org
2023-10-30 14:26 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-30 14:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> This is broken in two ways, you need to include both <algorithm> *and*
> <vector> for this program.
Actually three ways. There is no guarantee that std::vector's iterators have
namespace std as an associated namespace, so begin(v) and end(v) are not
guaranteed to find std::begin and std::end. You should qualify them or add
using declarations.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
2023-10-30 14:09 ` [Bug c++/112293] " redi at gcc dot gnu.org
2023-10-30 14:11 ` redi at gcc dot gnu.org
@ 2023-10-30 14:26 ` redi at gcc dot gnu.org
2023-10-30 14:30 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-30 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As I wrote in PR 82594, the error should say that the number of arguments is
wrong instead of the irrelevant error about converting to const char*.
I don't think a fix-it is likely here though.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
` (2 preceding siblings ...)
2023-10-30 14:26 ` redi at gcc dot gnu.org
@ 2023-10-30 14:30 ` redi at gcc dot gnu.org
2023-10-30 14:33 ` arkamar at atlas dot cz
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-30 14:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
FWIW the change in transitive includes was r14-1459-g940645cec500ab
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
` (3 preceding siblings ...)
2023-10-30 14:30 ` redi at gcc dot gnu.org
@ 2023-10-30 14:33 ` arkamar at atlas dot cz
2023-10-30 14:42 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: arkamar at atlas dot cz @ 2023-10-30 14:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #5 from Petr Vaněk <arkamar at atlas dot cz> ---
Thank you for the quick response and clarifications. I'll work on patching
rspamd to adhere to these requirements.
As for std::begin and std::end, rspamd uses them correctly, the std:: was
actually reduced by cvise in this case.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
` (4 preceding siblings ...)
2023-10-30 14:33 ` arkamar at atlas dot cz
@ 2023-10-30 14:42 ` redi at gcc dot gnu.org
2023-10-30 23:55 ` sjames at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-30 14:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> That would be difficult, because std::remove is overloaded and another
> overload was found here (the one declared in <cstdio>). Usually we only
> provide fix-it hints when name lookup doesn't find anything.
This is also a very unusual case. Most C++ std::lib functions are not
overloaded in C stdlib headers. Any change here would be quite specific to
std::remove, possibly even unique. There's std::bind which collides with POSIX
::bind. There are also std::isalnum etc. but I don't think it's possible to get
the problem there, since they're declared in the same header as the std::locale
type that you call them with.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
` (5 preceding siblings ...)
2023-10-30 14:42 ` redi at gcc dot gnu.org
@ 2023-10-30 23:55 ` sjames at gcc dot gnu.org
2024-01-21 20:50 ` redi at gcc dot gnu.org
2024-01-21 21:33 ` fw at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-10-30 23:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sjames at gcc dot gnu.org
--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
I think this has come up with chromium/nodejs v8 as well, in both cases with
people being confused about the stdio remove candidate at the end.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
` (6 preceding siblings ...)
2023-10-30 23:55 ` sjames at gcc dot gnu.org
@ 2024-01-21 20:50 ` redi at gcc dot gnu.org
2024-01-21 21:33 ` fw at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-21 20:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And here too: https://bugzilla.redhat.com/show_bug.cgi?id=2259394
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/112293] Enhance error reporting with fix-it for missing <algorithm> in gcc 14
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
` (7 preceding siblings ...)
2024-01-21 20:50 ` redi at gcc dot gnu.org
@ 2024-01-21 21:33 ` fw at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: fw at gcc dot gnu.org @ 2024-01-21 21:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293
Florian Weimer <fw at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fw at gcc dot gnu.org
--- Comment #9 from Florian Weimer <fw at gcc dot gnu.org> ---
Could we change the C++ standard not to declare std::remove in <cstdio>?
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-01-21 21:33 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30 13:51 [Bug c++/112293] New: Enhance error reporting with fix-it for missing <algorithm> in gcc 14 arkamar at atlas dot cz
2023-10-30 14:09 ` [Bug c++/112293] " redi at gcc dot gnu.org
2023-10-30 14:11 ` redi at gcc dot gnu.org
2023-10-30 14:26 ` redi at gcc dot gnu.org
2023-10-30 14:30 ` redi at gcc dot gnu.org
2023-10-30 14:33 ` arkamar at atlas dot cz
2023-10-30 14:42 ` redi at gcc dot gnu.org
2023-10-30 23:55 ` sjames at gcc dot gnu.org
2024-01-21 20:50 ` redi at gcc dot gnu.org
2024-01-21 21:33 ` fw 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).