www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/28/05:26:23

Message-ID: <41FBBB1B17AFD4119ECE000347088836F5A916@wbnsmail.gtl.com>
From: Rodney Leadbeater <rodney DOT leadbeater AT convergys DOT com>
To: "'djgpp-workers AT delorie DOT com'" <djgpp-workers AT delorie DOT com>
Subject: Array declarations allow non-constant expressions for dimensionin
g
Date: Thu, 28 Jun 2001 10:25:30 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp-workers AT delorie DOT com

Hi

Why does gcc allow the following? I was amazed that it allowed the
following. Very dangerous!!!

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


--

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019