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]

Non-constant expression allowed to dimension array declarations


Hi

I was amazed to see that gcc allows the following. It is extremely dangerous
in mixed-ability development teams! Could it not be turned on specifically
with a compiler flag if it has any raison d'etre?

#include <stdio.h>

int i = 20 ;
int j ;

int
main (int argc, char **argv)
{
int a_i [i] ;    // should not be allowed because of the danger
(traditionally use ma
lloc!)
int a_j [j] ;    // very dangerous

        printf ("sizeof a_i = %d\n", sizeof (a_i)) ;
        printf ("sizeof a_j = %d\n", sizeof (a_j)) ;
        return 0 ;
}

Regards


--

NOTICE:  The information contained in this electronic mail transmission is
intended by Convergys Corporation for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential.  If you have received this electronic
mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email
or by telephone (collect), so that the sender's address records can be
corrected.


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