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]

Re: Constant expression for array subscript operator


On Fri, Jul 20, 2001 at 09:36:42PM -0700, Timothy J. Wood wrote:
> 
> 
> > Should gcc emit an error message on the following piece of
> > code?  gcc 3.0.1 seems to compile it without complaining,
> > and only issues a warning if I add the -pedantic flag.
> >
> > #include <cstdio>
> > void foo(int a)
> > {
> >         char b[a];
> >         std::printf("Hello %c\n", b[9]);
> > }
> 
>    This is a non-standard GNU extension (which is useful, of course).
> 
>    See section 5.14 in http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_5.html 
> (and the rest of the page for more extensions).

Hi,

Thank you very much for your response, the URL you supplied
was very interesting.  For my project, portability to many
platforms and C++ compilers is more important than taking
advantage of GNU extensions.  In fact, the use-case that I
presented in my example was encountered recently in my project
where the code was developed and compiled under GCC, but was
rejected under other compilers such as Sun Workshop.

In my case, it would be nice if GCC defaulted to not using
GCC extensions when compiling C++ code, but I understand
that some people rely on these extensions.

I was wondering if the following patch could be accepted
to the documentation:

Index: extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.15
diff -u -r1.15 extend.texi
--- extend.texi 2001/07/17 11:58:53     1.15
+++ extend.texi 2001/07/21 08:51:31
@@ -10,7 +10,8 @@
 @opindex pedantic
 GNU C provides several language features not found in ISO standard C@.
 (The @option{-pedantic} option directs GCC to print a warning message if
-any of these features is used.)  To test for the availability of these
+any of these features is used, and @option{-pedantic-errors} treats these
+warnings as errors.)  To test for the availability of these
 features in conditional compilation, check for a predefined macro
 @code{__GNUC__}, which is always defined under GCC@.

-- 
Craig Rodrigues        
http://www.gis.net/~craigr    
rodrigc@mediaone.net          


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