public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/10138] warn for uninitialized arrays passed as const* arguments
Date: Mon, 20 Aug 2007 15:03:00 -0000	[thread overview]
Message-ID: <20070820150344.23758.qmail@sourceware.org> (raw)
In-Reply-To: <bug-10138-1038@http.gcc.gnu.org/bugzilla/>



------- Comment #12 from manu at gcc dot gnu dot org  2007-08-20 15:03 -------
(In reply to comment #11)
> (In reply to comment #10)
> > I now think that Andrew is right and that PR33086 and this one are INVALID.
> > 'const' does not mean read-only in C++ at all, and much less in C. atoi(const
> > char *) could always initialize buf[].
> 
> Uh, no, it can't. If it did (by casting away the 'const' from its argument
> and then writing into the array), this would lead to a segfault:
> -------------
> const char a[3] = "10";
> int main () {
>   return atoi (a);
> }
> -------------

This testcase has nothing to do with uninitialized variables. If the variable
is 'const' already, then there will never be a warning. Will it produce
segmentation fault for a local automatic uninitialized pointer?


-- 


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


  parent reply	other threads:[~2007-08-20 15:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-10138-1038@http.gcc.gnu.org/bugzilla/>
2007-08-16 10:57 ` manu at gcc dot gnu dot org
2007-08-20 14:49 ` manu at gcc dot gnu dot org
2007-08-20 14:56 ` bangerth at dealii dot org
2007-08-20 15:03 ` manu at gcc dot gnu dot org [this message]
2007-08-20 15:08 ` manu at gcc dot gnu dot org
2007-08-20 15:54 ` bangerth at dealii dot org
2007-08-20 16:15 ` manu at gcc dot gnu dot org
2007-08-20 16:22 ` bangerth at dealii dot org
2007-08-20 16:44 ` manu at gcc dot gnu dot org
2007-08-20 16:47 ` manu at gcc dot gnu dot org
2007-08-20 16:59 ` bangerth at dealii dot org
2007-08-20 17:12 ` manu at gcc dot gnu dot org
2007-08-20 18:51 ` gdr at cs dot tamu dot edu
2007-08-20 22:46 ` h dot b dot furuseth at usit dot uio dot no
2009-12-31  1:44 ` matt at use dot net
     [not found] <bug-10138-4@http.gcc.gnu.org/bugzilla/>
2015-08-12 11:15 ` mpolacek at gcc dot gnu.org
2020-05-15 23:32 ` msebor at gcc dot gnu.org
2020-06-04 22:10 ` cvs-commit at gcc dot gnu.org
2020-06-04 22:12 ` msebor at gcc dot gnu.org

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=20070820150344.23758.qmail@sourceware.org \
    --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).