https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81873
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This is not so much an -Wreturn-type issue but a symptom of the C++ front-end not merging decls for globals. You filed a few other cases which are accepts invalid which are the same here.