This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange gcc specific warning


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;
}   

=====================================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]