https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112267

--- Comment #4 from Fabio Alemagna <falemagn at gmail dot com> ---
With a tweak(In reply to Andrew Pinski from comment #3)
> (In reply to Fabio Alemagna from comment #1)
> > Changing the return type of the function func() from int to auto makes the
> > warning disappear.
> > 
> > Incidentally it causes an error on clang, though, which prompts the
> > question: is this a clang bug, for erroring out, or a gcc bug, for not
> > erroring out?
> 
> I tested MSVC also. It errors out with /std:c++20 but not with /std:c++17 so
> maybe there was a change for C++20 that clang decided it applies for
> previous C++ too (and GCC did not implement that rule yet).


Making the function a template, while keeping the return type as 'auto', and
making its template parameter depend on the template parameter of the caller,
solves the error and silences the warning on gcc.


Making the return value 'bool', even if the function is a template, still makes
the warning appear.


On Compiler Explorer: https://godbolt.org/z/E5qMT55MW

Reply via email to