public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++
@ 2011-10-17 12:10 roman.fietze at telemotive dot de
  2011-10-17 12:25 ` [Bug c++/50757] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: roman.fietze at telemotive dot de @ 2011-10-17 12:10 UTC (permalink / raw)
  To: gcc-bugs

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++.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/50757] Cannot turn off -Wnonnull when using C++
  2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
@ 2011-10-17 12:25 ` redi at gcc dot gnu.org
  2011-10-17 12:34 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-17 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-17
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-17 12:23:34 UTC ---
Confirmed, the diagnostic says it is controlled by -Wnonnull, but that's not a
valid option for G++

extern void *f (void *__s) __attribute__ ((__nonnull__ (1)));

int main()
{
    void* const s = 0;
    f(s);
}

w.cc:6:8: warning: null argument where non-null required (argument 1)
[-Wnonnull]

For G++ that warning is controlled by -Wformat/-Wno-format


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/50757] Cannot turn off -Wnonnull when using C++
  2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-17 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-17 12:33:41 UTC ---
Could be fixed by adding C++ and ObjC++ to the Wnonnull definition in
c-family/c.opt, or by adjusting the warning() in c-family/c-common.c to use
Wformat when compiling C++


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/50757] Cannot turn off -Wnonnull when using C++
  2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 12:43 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 12:43:13 UTC ---
Thanks for the analysis Jon, I can do it (quite similar to the
Wformat-zero-length issue, eh?)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/50757] Cannot turn off -Wnonnull when using C++
  2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-10-17 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-10-17 17:44:47 UTC ---
Author: paolo
Date: Mon Oct 17 17:44:42 2011
New Revision: 180101

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180101
Log:
/gcc
2011-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50757
    * c-family/c.opt ([Wnonnull]): Add C++ and Objective-C++.
    * doc/invoke.texi: Update.

/testsuite
2011-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50757
    * g++.dg/warn/format7.C: New.
    * obj-c++.dg/warn7.mm: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/warn/format7.C
    trunk/gcc/testsuite/obj-c++.dg/warn7.mm
Modified:
    trunk/gcc/c-family/c.opt
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/50757] Cannot turn off -Wnonnull when using C++
  2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 17:46:54 UTC ---
Fixed for 4.7.0.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/50757] Cannot turn off -Wnonnull when using C++
  2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
                   ` (4 preceding siblings ...)
  2011-10-17 17:47 ` paolo.carlini at oracle dot com
@ 2011-10-17 17:49 ` paolo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-10-17 17:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-10-17 17:49:10 UTC ---
Author: paolo
Date: Mon Oct 17 17:49:06 2011
New Revision: 180102

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180102
Log:
/gcc
2011-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50757
    * c-family/c.opt ([Wnonnull]): Add C++ and Objective-C++.
    * doc/invoke.texi: Update.

/testsuite
2011-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50757
    * g++.dg/warn/format7.C: New.
    * obj-c++.dg/warn7.mm: Likewise.

Modified:
    trunk/gcc/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-10-17 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-17 12:10 [Bug c++/50757] New: Cannot turn off -Wnonnull when using C++ roman.fietze at telemotive dot de
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

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).