public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39841]  New: -Wall on 'signed char' array subscript
@ 2009-04-21 21:46 ebb9 at byu dot net
  2009-04-21 21:53 ` [Bug c/39841] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: ebb9 at byu dot net @ 2009-04-21 21:46 UTC (permalink / raw)
  To: gcc-bugs

I appreciate the fact that gcc is able to warn about misuse of <ctype.h> macros
when they are written as an array access, when the programmer mistakenly uses
'char' (under -fsigned-char) instead of the standard-mandated int containing an
unsigned char value (there is discussion right now on the newlib list about
rewriting isalpha and friends in a manner more conducive to triggering this
warning, http://sourceware.org/ml/newlib/2009/msg00511.html).

However, I expected that gcc would also warn about 'signed char':

$ cat foo.c
signed char ch;
int array[1];
int main ()
{
  return array[ch];
}
$ gcc -Wall -c -o foo.o foo.c -Dsigned=
foo.c: In function 'main':
foo.c:5: warning: array subscript has type 'char'
$ gcc -Wall -c -o foo.o foo.c
$


-- 
           Summary: -Wall on 'signed char' array subscript
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ebb9 at byu dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39841


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/39841] -Wall on 'signed char' array subscript
  2009-04-21 21:46 [Bug c/39841] New: -Wall on 'signed char' array subscript ebb9 at byu dot net
@ 2009-04-21 21:53 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-21 21:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-04-21 21:53 -------
The reasoning behind signed char not giving a warning is because in C/C++, char
can either be unsigned or signed depending on the target so the warning is only
for char and not for the specific marked signed character types.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39841


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-21 21:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-21 21:46 [Bug c/39841] New: -Wall on 'signed char' array subscript ebb9 at byu dot net
2009-04-21 21:53 ` [Bug c/39841] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).