[IPOL discuss] small compilation error in LSD code (ubuntu 11.10)

Miguel Colom Miguel.Colom at cmla.ens-cachan.fr
Wed Nov 16 15:35:09 CET 2011


> In the main function, and because of the lack of declaration, the
> function gsl_matrix_read gets an implicit prototype, where the return
> type is a int, instead of gsl_matrix* which I suppose is a long int
> (the pointer I mean). For that reason, the pointer M in the main
> function get its address truncated only to the lowest 32 bits of the
> address.
>
> I know this was my fault, but well, I expected more from a decent
> compiler.

What is really worrying is not the function getting an implicit prototype,
but the compiler not complaining about the conflicting type conversion.

I mean, you declared a pointer to some data type and it got converted into
a int.

This conversion isn't valid and it shouldn't even compile.

In my gcc 4.5.2, in such a situation, it gives an conversion error and a
"note" about the implicit declaration:

main.c:11:13: error: conflicting types for ‘gsl_matrix_read’
main.c:7:3: note: previous implicit declaration of ‘gsl_matrix_read’ was here

I can understand the note not being showed, but trying an invalid
conversion is an error, not a warning.

Miguel



More information about the discuss mailing list