https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90219
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Timm Bäder from comment #0) > Using gcc 8.3.1 and the following sample code: > > static int use_float(float *f) { > return (int)*f; > } > > // Type your code here, or load an example. > int square(int num) { > float f = 1.0f; > return use_float((float*)f); > } > > it prints the following error: > > <source>: In function 'square': > <source>:8:5: error: cannot convert to a pointer type > return use_float((float*)f); > ^~~~~~ > > which is highlighting the wrong part of that line. The error message itself > could be improved as well (I forgot to take the address of f of course!) Well if you took the address you wouldn't need to cast it to (float*) so I don't think the diagnostic should try to infer that you wanted to say &f here. It certainly looks like the code is attempting to do an invalid type conversion, so the message seems reasonable. The highlighted location is definitely poor though. > but > I think the cast should be highlighted. > > If use_float() is instead called stand-alone and not as part of the return > statment: > > int square(int num) { > float f = 1.0f; > use_float((float*)f); > return 1; > } > > The source location is slightly better: > > <source>: In function 'square': > <source>:8:5: error: cannot convert to a pointer type > use_float((float*)f); > ^~~~~~~~~ Well it's still just the start of the statement, which is not really any better.