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: unassig...@gcc.gnu.org
        ReportedBy: roman.fie...@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 via email to