[IPOL discuss] small compilation error in LSD code (ubuntu 11.10)
Juan Cardelino
juan.cardelino at gmail.com
Wed Nov 16 13:42:33 CET 2011
On Wed, Nov 16, 2011 at 10:22 AM, Nicolas Limare
<nicolas.limare at cmla.ens-cachan.fr> wrote:
> On Wed, Nov 16, 2011 at 12:38:36PM +0100, Pascal Monasse wrote:
>> Me too. Switching to gcc 4.6 opened Pandora's box, with lots of bugs. I know
>> also this is for my own good, but this is not very pleasant when it
>> happens...
>
> Does gcc 4.6 give more errors and warnings than the previous version
> and warnings when called with
> -std=c99 -Wall -Wextra -Werror
> or is the difference only in the default set of errors and warnings
> reported in basic compilation (without standard and warning option)?
>
I don't think so, I've recompiled all my code (~30k lines) and didn't
have any new warnings.
A problem I found recently with gcc, it is not warning me anymore
about undeclared functions. Maybe there is a new flag to ask him to
warn about that. This lack of warning turned into a nasty error, see
this example:
int main()
{
M=gsl_matrix_read("matrix.txt");
//M here gets an invalid value
}
gsl_matrix *read_matrix(const char* filename)
{
gsl_matrix* m= gsl_matrix_alloc(10,10);
//more stuff here
return m;
}
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 didn't realize about this until I compiled with clang and told me
that there was an undeclared function.
I know this was my fault, but well, I expected more from a decent compiler.
> Next (masochistic) test: compile with different compilers, such as icc
> (gcc-compatible front-end), suncc (completely different compiler),
> msvc...
>
I'm trying to work all the time with clang and gcc. Don't have time
for more, I need to keep my masochism controlled :D
More information about the discuss
mailing list