[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-11-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Jonathan Wakely  changed:

   What|Removed |Added

   Target Milestone|--- |9.0
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=77299

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-11-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Andrew Pinski  changed:

   What|Removed |Added

  Known to work||9.1.0
 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #15 from Andrew Pinski  ---
Note the original issue with -Wzero-as-null-pointer-constant is fixed in GCC 9
by r9-873. The system header issue is now listed as PR 77299.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-11-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #14 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #13)
> An intereting case from PR 103347 where the pedwarn about the NSDMI is
> suppressed because GCC thinks the initializer is in a system header:
> 
> #include 
> struct test {
> void *x = NULL; //invalid in C++03 mode
> };
> int main() {}
> 
> This should be rejected with -pedantic-errors, but g++ is silent unless you
> also add -Wsystem-headers.

And this is a regression, because 4.8 silently accepts this code in C++98 mode,
whereas 4.7 warns about it as expected:

null.C:3:15: warning: non-static data member initializers only available with
-std=c++11 or -std=gnu++11 [enabled by default]

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-11-21 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Jonathan Wakely  changed:

   What|Removed |Added

   Last reconfirmed|2021-08-27 00:00:00 |2021-11-21

--- Comment #13 from Jonathan Wakely  ---
An intereting case from PR 103347 where the pedwarn about the NSDMI is
suppressed because GCC thinks the initializer is in a system header:

#include 
struct test {
void *x = NULL; //invalid in C++03 mode
};
int main() {}

This should be rejected with -pedantic-errors, but g++ is silent unless you
also add -Wsystem-headers.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-11-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Andrew Pinski  changed:

   What|Removed |Added

 CC||fchelnokov at gmail dot com

--- Comment #12 from Andrew Pinski  ---
*** Bug 103347 has been marked as a duplicate of this bug. ***

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-08-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Last reconfirmed||2021-08-27

--- Comment #11 from Andrew Pinski  ---
Confirmed.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2021-08-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Andrew Pinski  changed:

   What|Removed |Added

 CC||wipedout at yandex dot ru

--- Comment #10 from Andrew Pinski  ---
*** Bug 77299 has been marked as a duplicate of this bug. ***

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #9 from Jonathan Wakely  ---
(In reply to Ville Voutilainen from comment #7)
> "The macro NULL is an implementation-defined null pointer constant.", says
> the C++ standard draft.

So it does, maybe I was misremembering something from an older C++0x draft.

Either way, 0 is still a valid definition of NULL, and I suspect that defining
NULL as nullptr would break a lot of code (albeit bad code that is misusing
NULL).

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2018-05-30 Thread ville.voutilainen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #8 from Ville Voutilainen  ---
See r260973

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2018-05-30 Thread ville.voutilainen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Ville Voutilainen  changed:

   What|Removed |Added

 CC||ville.voutilainen at gmail dot 
com

--- Comment #7 from Ville Voutilainen  ---
"The macro NULL is an implementation-defined null pointer constant.", says the
C++ standard draft.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2018-05-24 Thread falemagn at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Fabio Alemagna  changed:

   What|Removed |Added

 CC||falemagn at gmail dot com

--- Comment #6 from Fabio Alemagna  ---
(In reply to Jonathan Wakely from comment #3)
> (In reply to petschy from comment #0)
> > For c++11 and later code, why is NULL defined as __null, rather than 
> > nullptr?
> 
> Because defining NULL as nullptr would violate the requirements of the
> standard, which very intentionally says that NULL is an integral constant
> expression, not nullptr.

I don't know how autoritative is it, but cppreference.com says that since
C++11,  NULL is

an integer literal with value zero, or a prvalue of type std::nullptr_t

See: http://en.cppreference.com/w/cpp/types/NULL

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2016-09-16 Thread petschy at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #5 from petschy at gmail dot com ---
Some more details, hope this helps. Preprocessed one of the oddly behaving
files with 5.4.1, 6.2.1 and 7.0.0, then tried to compile each preprocessed file
with each compiler version. 5.4.1 warned for all preprocessed files, 6.2.1 and
7.0.0 didn't warn for any of them. This doesn't mean that 6.2.1 and 7.0.0 is
not affected, just for this particular file they didn't warn. 

Diffing the files revealed that there is no difference in the user code, only
in the system headers included, eg  comes from
/usr/local/include/c++/5.4.1/string for 5.4.1, etc.

All of the problematic lines are assignments of the form
  var = NULL;
or
  var1 = var2 = NULL;

ALL of the NULL assignments in the file are reported.
NONE of the == or != tests are reported.

Eg: this code warns:

AbstractImage::AbstractImage()
{
 pixels=
# 124 "common/src/AbstractImage.cpp" 3 4
   __null
# 124 "common/src/AbstractImage.cpp"
   ;
 channels_n=0;
 mode=255;
 width=-1;
 height=-1;
}

But if I replace 'pixels =' with 'bool b = pixels ==' above, the warning
disappears, which is strange, I think.

The flags are the same for the != and == tests, ie 
#  "common/src/AbstractImage.cpp" 3 4
is everywhere.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2016-09-07 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

Manuel López-Ibáñez  changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #4 from Manuel López-Ibáñez  ---
(In reply to petschy from comment #2)
> Here I see the same flags, yet for these two NULLs gcc warns.

prog.cc:6:28: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
 , false, false };
^

because the location given is wrong, so the location in this case is not within
the system-header flags. If the location was right (under __null), it would not
warn. That is the bug.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2016-09-07 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #3 from Jonathan Wakely  ---
(In reply to petschy from comment #0)
> For c++11 and later code, why is NULL defined as __null, rather than nullptr?

Because defining NULL as nullptr would violate the requirements of the
standard, which very intentionally says that NULL is an integral constant
expression, not nullptr.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2016-09-07 Thread petschy at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #2 from petschy at gmail dot com ---
I don't want to enable them. The problem is not with too little but too many
warnings.

A snippet from one of the problematic files:

{ NULL, NULL, false, false }

is preprocessed to 

 { 
# 62 "AdsPlugin.cpp" 3 4
  __null
# 62 "AdsPlugin.cpp"
  , 
# 62 "AdsPlugin.cpp" 3 4
__null
# 62 "AdsPlugin.cpp"
, false, false }
};

Here I see the same flags, yet for these two NULLs gcc warns.

[Bug c++/77513] -Wzero-as-null-pointer-constant vs 0, nullptr, NULL and __null

2016-09-07 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513

--- Comment #1 from Andreas Schwab  ---
The "3" flag on the line marker marks the following lines as originating from a
system header where warnings are suppressed.  Use -Wsystem-headers to enable
them.