This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Strange gcc specific warning
- From: Frank Klemm <pfk at fuchs dot offl dot uni-jena dot de>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 24 Jan 2003 05:30:27 +0100
- Subject: Strange gcc specific warning
- >received: (from pfk@localhost)by fuchs.offl.uni-jena.de (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id FAA02609for gcc@gcc.gnu.org; Fri, 24 Jan 2003 05:30:27 +0100
Hi,
gcc is the only compiler which complains about passing R/W arrays to a read
only function. Can this been removed?
Otherwise most people will remove this warning by removing the const from
the print() function.
=====================================================================
/*
* gcc: strange warning, why ???
* g++: okay
* all other compilers: okay, no warning
*/
#include <stdio.h>
void
print ( /* IN */ const float A [2] [16] )
{
int i;
int j;
for ( i = 0; i < 2; i++ ) {
for ( j = 0; j < 16; j++ )
printf ("%12.6f", A [i] [j] );
printf ( "\n" );
}
}
void
invert ( /* IN OUT */ float A [2] [16] )
{
int i;
int j;
for ( i = 0; i < 2; i++ )
for ( j = 0; j < 16; j++ )
A [i] [j] = -A [i] [j];
}
int
main ( void )
{
float Array [2] [16];
invert ( Array );
print ( Array );
return 0;
}
=====================================================================