[Bug c/107091] Misleading error message "incompatible types when returning ..."

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 29 21:18:02 GMT 2022


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-09-29
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang produces:
<source>:3:12: error: returning 'void *' from a function with incompatible
result type 'double'
    return (void *)0;
           ^~~~~~~~~

MSVC produces:

<source>(3): error C2440: 'return': cannot convert from 'void *' to 'double'

ICC Produces:
<source>(3): error: return value type does not match the function type
      return (void *)0;
             ^

cproc (https://github.com/michaelforney/cproc) produces:
<source>:2:22: error: assignment to arithmetic type must be from arithmetic
type


MSVC seems similar to what is produced for GCC's C++ front-end.
I don't know the best wording here really because convert might even be wrong.


More information about the Gcc-bugs mailing list