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

            Bug ID: 121783
           Summary: Wrong diagnostics for incompatible character pointer
                    assignments
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.lundin.mail at gmail dot com
  Target Milestone: ---

Compiling with -std=c23 -pedantic-errors -Wall -Wextra.

When attempting incorrect implicit pointer conversions between the 3 character
types, I get misleading diagnostic messages. Example:

char* c;
signed char* sc;
unsigned char* uc;
c=sc;
c=uc;

error: pointer targets in assignment from 'signed char *' to 'char *' differ in
signedness [-Wpointer-sign]
error: pointer targets in assignment from 'unsigned char *' to 'char *' differ
in signedness [-Wpointer-sign]

This is wrong, char obviously has the same signedness as either signed char or
unsigned char but not both at once. The actual problem is rather that they are
pointers to different types regardless of signedness.

clang has a somewhat better (at least not incorrect) message:

error: assigning to 'char *' from 'signed char *' converts between pointers to
integer types where one is of the unique plain 'char' type and the other is not
[-Werror,-Wpointer-sign]
  • [Bug c/121783] New: Wrong... daniel.lundin.mail at gmail dot com via Gcc-bugs

Reply via email to