public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "christoph dot wintersteiger at inf dot ethz dot ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/31712]  New: no warning on implicit cast from int to pointer
Date: Thu, 26 Apr 2007 11:11:00 -0000	[thread overview]
Message-ID: <bug-31712-14469@http.gcc.gnu.org/bugzilla/> (raw)

Mixing up variables when working with strings does not trigger a warning.

Example:

int main(void)
{
int plen;
char *ptr;

plen[ptr]='\0'; /* (char*)'th element of an int */

return 0;
}

in line 6, plen[ptr]='\0';, plen is implicitly casted to a pointer and ptr is
implicitly casted to an unsigned. At least when casting the int to a pointer,
there should be a warning. 

This behavior can be reproduced in, at least, versions 2.95, 3.2.3 and 4.1.2 of
gcc. Adding -Wall -g -ansi -pedantic -std=c99 does not help.


-- 
           Summary: no warning on implicit cast from int to pointer
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christoph dot wintersteiger at inf dot ethz dot ch
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


             reply	other threads:[~2007-04-26 11:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-26 11:11 christoph dot wintersteiger at inf dot ethz dot ch [this message]
2007-04-26 11:12 ` [Bug c/31712] " christoph dot wintersteiger at inf dot ethz dot ch
2007-04-26 11:18 ` schwab at suse dot de
2007-04-26 11:32 ` christoph dot wintersteiger at inf dot ethz dot ch
2007-04-26 14:56 ` pinskia at gcc dot gnu dot org
2007-04-26 15:04 ` christoph dot wintersteiger at inf dot ethz dot ch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31712-14469@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).