https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123134

            Bug ID: 123134
           Summary: no warning for unsigned long assigned to pointer
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

In bug report 123128, Jakub Jelinek points out that
clang and gcc disagree on the following code:

 int *p = ((unsigned long int) 0);

Here are some attempts to get gcc to find the problem:

Alphasrc $ g++ -g -O2 -c -Wall -Wextra -pedantic dec15b.cc
Alphasrc $

So Fedora stock gcc can't find the problem.
For a recent gcc trunk

Alphasrc $ ~/gcc/results/bin/g++ -g -O2 -c -Wall -Wextra -pedantic dec15b.cc
Alphasrc $

And for clang:

Alphasrc $ clang++ -c dec15b.cc
clang++ -c dec15b.cc
dec15b.cc:6:7: error: cannot initialize a variable of type 'int *' with an
rvalue of type 'unsigned long'
    6 |         int *p = ((unsigned long int) 0);
      |              ^   ~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Alphasrc $ 

Code is

extern void g( int *);

void f1()
{
        int *p = ((unsigned long int) 0);

        g( p);
}

Reply via email to