This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Non-constant expression allowed to dimension array declarations
- To: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Subject: Non-constant expression allowed to dimension array declarations
- From: Rodney Leadbeater <rodney dot leadbeater at convergys dot com>
- Date: Thu, 28 Jun 2001 10:35:45 +0100
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.