This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50757] New: Cannot turn off -Wnonnull when using C++
- From: "roman.fietze at telemotive dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 17 Oct 2011 12:09:40 +0000
- Subject: [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++
- Auto-submitted: auto-generated
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++.