Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Paul Eggert
Fri, 07 Aug 1992 22:44
GCC 2.2.2 does not warn about `1<=i<=N'
Author: Paul Eggert
Date: Fri, 07 Aug 1992 22:44
Date: Fri, 07 Aug 1992 22:44
45 lines
2075 bytes
2075 bytes
GCC 2.2.2 does not warn about C expressions like `1<=i<=N', which have
a different meaning than in traditional mathematics. Here is a patch.
Fri Aug 7 22:34:20 1992 Paul Eggert (eggert@twinsun.com)
* c-typeck.c (parser_build_binary_op): Warn about expressions like
`1<=i<=N'.
* invoke.texi: Document warning.
===================================================================
RCS file: invoke.texi,v
retrieving revision 2.2.2.1
diff -c2 -r2.2.2.1 invoke.texi
*** invoke.texi 1992/08/01 03:27:09 2.2.2.1
--- invoke.texi 1992/08/07 22:22:36
***************
*** 616,619 ****
--- 616,624 ----
@item
+ A comparison like @samp{x<=y<=z} appears; this is equivalent to
+ @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation than
+ ordinary mathmatics.
+
+ @item
A storage-class specifier like @code{static} appears other than
at the beginning of a declaration. According to the C Standard,
===================================================================
RCS file: c-typeck.c,v
retrieving revision 2.2.2.3
diff -c2 -r2.2.2.3 c-typeck.c
*** c-typeck.c 1992/07/18 03:33:06 2.2.2.3
--- c-typeck.c 1992/08/07 22:34:20
***************
*** 2131,2134 ****
--- 2131,2139 ----
class = TREE_CODE_CLASS (TREE_CODE (result));
+ /* Similarly, check for cases like 1<=i<=10 that are probably errors. */
+ if (class == '<' && extra_warnings
+ && (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<'))
+ warning ("comparisons like X<=Y<=Z do not have the usual meaning");
+
/* Record the code that was specified in the source,
for the sake of warnings about confusing nesting. */
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads