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