GCC 12 warns too much about <regex>
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562 * m4/gccwarn.m4: Compile a small regex and add -Wno-maybe-uninitialized if needed.
This commit is contained in:
parent
10bc253dd8
commit
99d030f5e1
1 changed files with 31 additions and 8 deletions
|
|
@ -21,6 +21,7 @@ AC_DEFUN([CF_GXX_WARNINGS],
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line __oline__ "configure"
|
#line __oline__ "configure"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
int main(int argc, char *argv[[]])
|
int main(int argc, char *argv[[]])
|
||||||
{
|
{
|
||||||
// This string comparison is here to detect superfluous
|
// This string comparison is here to detect superfluous
|
||||||
|
|
@ -33,19 +34,26 @@ int main(int argc, char *argv[[]])
|
||||||
std::string a{"foo"}, b{"bar"};
|
std::string a{"foo"}, b{"bar"};
|
||||||
if (b < a)
|
if (b < a)
|
||||||
return 1;
|
return 1;
|
||||||
|
// GCC 12 has spurious warnings about ininialized values in regex.
|
||||||
|
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562
|
||||||
|
// We need -Wno-maybe-uninitialized in this case.
|
||||||
|
std::regex r{"a"};
|
||||||
|
(void)r;
|
||||||
return argv[[argc-1]] == nullptr;
|
return argv[[argc-1]] == nullptr;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
cf_save_CXXFLAGS="$CXXFLAGS"
|
cf_save_CXXFLAGS="$CXXFLAGS"
|
||||||
ac_cv_prog_gxx_warn_flags="-W -Wall"
|
ac_cv_prog_gxx_warn_flags="-W -Werror"
|
||||||
|
dnl The following list has options of the form OPT:BAD:GOOD
|
||||||
|
dnl if -OPT fails we try -OPT -BAD. If -OPT succeeds we add -GOOD.
|
||||||
for cf_opt in \
|
for cf_opt in \
|
||||||
Werror \
|
Wall:Wno-maybe-uninitialized:\
|
||||||
Wint-to-void-pointer-cast \
|
Wint-to-void-pointer-cast \
|
||||||
Wzero-as-null-pointer-constant \
|
Wzero-as-null-pointer-constant \
|
||||||
Wcast-align \
|
Wcast-align \
|
||||||
Wpointer-arith \
|
Wpointer-arith \
|
||||||
Wwrite-strings \
|
Wwrite-strings \
|
||||||
Wcast-qual \
|
Wcast-qual::DXTSTRINGDEFINES \
|
||||||
Wdocumentation \
|
Wdocumentation \
|
||||||
Wmissing-declarations \
|
Wmissing-declarations \
|
||||||
Wnoexcept \
|
Wnoexcept \
|
||||||
|
|
@ -58,10 +66,25 @@ EOF
|
||||||
Wsuggest-override \
|
Wsuggest-override \
|
||||||
Wpedantic
|
Wpedantic
|
||||||
do
|
do
|
||||||
CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$cf_opt"
|
fopt=${cf_opt%%:*}
|
||||||
|
CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$fopt"
|
||||||
if AC_TRY_EVAL(ac_compile); then
|
if AC_TRY_EVAL(ac_compile); then
|
||||||
ac_cv_prog_gxx_warn_flags="$ac_cv_prog_gxx_warn_flags -$cf_opt"
|
ac_cv_prog_gxx_warn_flags="$ac_cv_prog_gxx_warn_flags -$fopt"
|
||||||
test "$cf_opt" = Wcast-qual && ac_cv_prog_gxx_warn_flags="$ac_cv_prog_gxx_warn_flags -DXTSTRINGDEFINES"
|
case $cf_opt in
|
||||||
|
*:*:);;
|
||||||
|
*:*:*)ac_cv_prog_gxx_warn_flags="$ac_cv_prog_gxx_warn_flags -${cf_opt##*:}";;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
case $cf_opt in
|
||||||
|
*::*);;
|
||||||
|
*:*:*)
|
||||||
|
sopt=${cf_opt%:*}
|
||||||
|
sopt=${sopt#*:}
|
||||||
|
CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$fopt -$sopt"
|
||||||
|
if AC_TRY_EVAL(ac_compile); then
|
||||||
|
ac_cv_prog_gxx_warn_flags="$ac_cv_prog_gxx_warn_flags -$fopt -$sopt"
|
||||||
|
fi;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -f conftest*
|
rm -f conftest*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue