public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "roman.fietze at telemotive dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++
Date: Mon, 17 Oct 2011 12:10:00 -0000	[thread overview]
Message-ID: <bug-50757-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             Bug #: 50757
           Summary: Cannot turn off -Wnonnull when using C++
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: roman.fietze@telemotive.de


When using gcc e.g. in embedded systems it can happen that valid memory regions
start at address 0x0. E.g. in our System a huge DDR2 starts at 0x0, and we
cannot move it easily or even reserve page 0.

Although it is almost impossible, that the start address of a format string
will be at address 0, there's still the possibility, that this is "normal"
memory that has to be used by the application, e.g as a buffer.

Therefore it might happen that one wants to write something like

  memset(myptr, 0, mysize);

or

  memcpy(myptr, mydata, datasize);

with myptr beeing 0, or even worse, constant 0 (char * const myptr = 0x0;)

Trying to turn -Wnonnull off (which is being turned on automatically using
-Wall/-Wformat) using e.g. this command line

  g++-4.6  -Wall [-Werror] -Wno-nonnull ...

causes an error

  cc1plus: warning: command line option ‘-Wno-nonnull’ is valid for C/ObjC but
not for C++ ...

If it is allowed to implicitly turn on -Wnonnull it must also be allowed to
turn it off again. Even in C++.


             reply	other threads:[~2011-10-17 12:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 12:10 roman.fietze at telemotive dot de [this message]
2011-10-17 12:25 ` [Bug c++/50757] " redi at gcc dot gnu.org
2011-10-17 12:34 ` redi at gcc dot gnu.org
2011-10-17 12:43 ` paolo.carlini at oracle dot com
2011-10-17 17:45 ` paolo at gcc dot gnu.org
2011-10-17 17:47 ` paolo.carlini at oracle dot com
2011-10-17 17:49 ` paolo 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=bug-50757-4@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).