[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2024-01-21 Thread fw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

Florian Weimer  changed:

   What|Removed |Added

 CC||fw at gcc dot gnu.org

--- Comment #9 from Florian Weimer  ---
Could we change the C++ standard not to declare std::remove in ?

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2024-01-21 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #8 from Jonathan Wakely  ---
And here too: https://bugzilla.redhat.com/show_bug.cgi?id=2259394

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

Sam James  changed:

   What|Removed |Added

 CC||sjames at gcc dot gnu.org

--- Comment #7 from Sam James  ---
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.

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #6 from Jonathan Wakely  ---
(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 ). 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.

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread arkamar at atlas dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #5 from Petr Vaněk  ---
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.

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #4 from Jonathan Wakely  ---
FWIW the change in transitive includes was r14-1459-g940645cec500ab

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #3 from Jonathan Wakely  ---
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.

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #2 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #1)
> This is broken in two ways, you need to include both  *and*
>  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.

[Bug c++/112293] Enhance error reporting with fix-it for missing in gcc 14

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112293

--- Comment #1 from Jonathan Wakely  ---
(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  header (this part is
> likely a bug within rspamd).

The C++ standard always required the explicit inclusion of  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  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 ). Usually we only provide fix-it
hints when name lookup doesn't find anything.

> Here is the minimized snippet to reproduce the issue:
> 
> #include 
> #include 
> struct test;
> std::vector 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  *and* 
for this program.