https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112267
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (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).