[Webnucleo-bugs] Example bug report (Bugs in example1.c in wn_matrix, version 0.2)

Bradley S. Meyer mbradle at clemson.edu
Sun Jul 15 22:46:35 EDT 2007


On Sun, July 15, 2007 5:37 pm, John Q. BugReporter wrote:

> When I compile example1.c in the src/examples directory of wn_matrix
> version 0.2 with gcc with the added compiler flags
>
> -Werror -Wconversion -Wstrict-prototypes
>
> (I attach the Makefile that I used), I get the following compilation
> errors:
>
> example1.c:46: warning: function declaration isn't a prototype
> example1.c: In function `main':
> example1.c:162: warning: passing arg 4 of `WnMatrix__assignElement' as
> floating rather than integer due to prototype
> example1.c:193: warning: passing arg 4 of `WnMatrix__assignElement' as
> floating rather than integer due to prototype
> make: *** [tmp/example1.o] Error 1
>
> The errors are due to the main prototype and the fact that example1.c is
> passing an int in two places where it should pass a double.
>

We confirm these errors in wn_matrix/0.2/src/examples/example1.c when we
compile with your Makefile.  They are also present when we compile
examples2-5.c.  Since we desire our code to be portable and reliable, it
should compile with the flags you have added.  To ensure potability and
reliability we will henceforth compile all our codes with the gcc warning
options recommended in the GNU Scientific Library Reference Manual:

http://www.gnu.org/software/gsl/manual/html_node/GCC-warning-options-for-numerical-programs.html

with the exception of -Wtraditional since that seems to conflict with libxml.

> I have a new version of example1.c (called example1_new.c) that compiles
> correctly with the new flags.  When I run
>
> diff example1.c example1_new.c
>
> I get the changes:
>
> 46c46
> < int main() {
> ---
>> int main( void ) {
> 162c162
> <   WnMatrix__assignElement( p_my_matrix, 1, 1, 1 );
> ---
>>   WnMatrix__assignElement( p_my_matrix, 1, 1, 1. );
> 193c193
> <   WnMatrix__assignElement( p_my_matrix, 1, 1, 1 );
> ---
>>   WnMatrix__assignElement( p_my_matrix, 1, 1, 1. );
>

Thanks for those suggested changes.  They've been applied and committed.
They will appear in all relevant examples along with the updated Makefile
in the next version of wn_matrix.

-- 
Bradley S. Meyer
Department of Physics and Astronomy
Clemson University
Clemson, SC 29634-0978
mbradle at clemson.edu
http://nucleo.ces.clemson.edu



More information about the Webnucleo-bugs mailing list