This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
-pedantic, string length (was: Re: Changes to gcc.c (display_help))
- To: gcc-patches at gcc dot gnu dot org
- Subject: -pedantic, string length (was: Re: Changes to gcc.c (display_help))
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Tue, 27 Jun 2000 20:20:38 +0100 (BST)
Kaveh R. Ghazi wrote:
> + if (pedantic && nchars > 508)
> + pedwarn ("string length %d is greater than ANSI C maximum 508", nchars);
The value - after concatenation but in my reading excluding the added NUL
- is 509 in C89 and 4095 in C99 and flag_isoc99 should be taken account of
accordingly. My best interpretation of the standard wording is that this
is meant to refer to source multibyte characters before conversion to an
array of char or wchar_t; but multibyte correctness for this warning can
probably be attended to when full support for multibyte source and \u
escapes is implemented. While in this part of the compiler, a C89-only
-pedantic warning for concatenating ordinary and wide string literals
would make sense.
The requirement is actually to translate and execute at least one program
containing a string of length 509 or 4095 (along with the other minimum
limits) rather than to reject longer strings - a footnote discourages
fixed translation limits - but having such a -pedantic warning, using the
appropriate limit for the standard version selected, seems reasonable.
Saying "minimum limit" rather than "maximum" might more accurately reflect
the standards. (This is a limit which has actually been included in
compilers, so the warning is useful.)
Here's a patch to make the documentation of -pedantic accord more closely
with reality, and to remove the anti-standards political statement
associated with it (since GCC does evidently find -pedantic now useful).
2000-06-27 Joseph S. Myers <jsm28@cam.ac.uk>
* invoke.texi (-pedantic): Refer to ISO C instead of ANSI C, and
update to describe current practice.
--- invoke.texi Tue Jun 27 06:35:50 2000
+++ invoke.texi.new Tue Jun 27 18:56:41 2000
@@ -1436,10 +1436,12 @@
Check the code for syntax errors, but don't do anything beyond that.
@item -pedantic
-Issue all the warnings demanded by strict ANSI C and ISO C++;
-reject all programs that use forbidden extensions.
+Issue all the warnings demanded by strict ISO C and ISO C++;
+reject all programs that use forbidden extensions, and some other
+programs that do not follow ISO C and ISO C++. For ISO C, follows the
+version of the ISO C standard specified by any @samp{-std} option used.
-Valid ANSI C and ISO C++ programs should compile properly with or without
+Valid ISO C and ISO C++ programs should compile properly with or without
this option (though a rare few will require @samp{-ansi}). However,
without this option, certain GNU extensions and traditional C and C++
features are supported as well. With this option, they are rejected.
@@ -1451,16 +1453,13 @@
these escape routes; application programs should avoid them.
@xref{Alternate Keywords}.
-This option is not intended to be @i{useful}; it exists only to satisfy
-pedants who would otherwise claim that GCC fails to support the ANSI
-standard.
-
-Some users try to use @samp{-pedantic} to check programs for strict ANSI
+Some users try to use @samp{-pedantic} to check programs for strict ISO
C conformance. They soon find that it does not do quite what they want:
it finds some non-ANSI practices, but not all---only those for which
-ANSI C @emph{requires} a diagnostic.
+ISO C @emph{requires} a diagnostic, and some others for which
+diagnostics have been added.
-A feature to report any failure to conform to ANSI C might be useful in
+A feature to report any failure to conform to ISO C might be useful in
some instances, but would require considerable additional work and would
be quite different from @samp{-pedantic}. We don't have plans to
support such a feature in the near future.
--
Joseph S. Myers
jsm28@cam.ac.uk