[Bug c/111884] [13/14 Regression] unsigned char no longer aliases anything under -std=c2x

2023-10-20 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111884

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org
 Resolution|--- |FIXED

--- Comment #7 from Marek Polacek  ---
Fixed.

[Bug c/111884] [13/14 Regression] unsigned char no longer aliases anything under -std=c2x

2023-10-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111884

--- Comment #6 from CVS Commits  ---
The releases/gcc-13 branch has been updated by Marek Polacek
:

https://gcc.gnu.org/g:4f93c6027fb09c94ca8dc7fe13f92a3b9205b68a

commit r13-7967-g4f93c6027fb09c94ca8dc7fe13f92a3b9205b68a
Author: Marek Polacek 
Date:   Thu Oct 19 16:32:10 2023 -0400

c-family: char8_t and aliasing in C vs C++ [PR111884]

In the PR, Joseph says that in C char8_t is not a distinct type.  So
we should behave as if it can alias anything, like ordinary char.
In C, unsigned_char_type_node == char8_type_node, so with this patch
we return 0 instead of -1.  And the following comment says:

  /* The C standard guarantees that any object may be accessed via an
 lvalue that has narrow character type (except char8_t).  */
  if (t == char_type_node
  || t == signed_char_type_node
  || t == unsigned_char_type_node)
return 0;

Which appears to be wrong, so I'm adjusting that as well.

PR c/111884

gcc/c-family/ChangeLog:

* c-common.cc (c_common_get_alias_set): Return -1 for char8_t only
in C++.

gcc/testsuite/ChangeLog:

* c-c++-common/alias-1.c: New test.

(cherry picked from commit 281699fbff6262766674ab13087d37db751cd40a)

[Bug c/111884] [13/14 Regression] unsigned char no longer aliases anything under -std=c2x

2023-10-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111884

--- Comment #5 from CVS Commits  ---
The trunk branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:281699fbff6262766674ab13087d37db751cd40a

commit r14-4802-g281699fbff6262766674ab13087d37db751cd40a
Author: Marek Polacek 
Date:   Thu Oct 19 16:32:10 2023 -0400

c-family: char8_t and aliasing in C vs C++ [PR111884]

In the PR, Joseph says that in C char8_t is not a distinct type.  So
we should behave as if it can alias anything, like ordinary char.
In C, unsigned_char_type_node == char8_type_node, so with this patch
we return 0 instead of -1.  And the following comment says:

  /* The C standard guarantees that any object may be accessed via an
 lvalue that has narrow character type (except char8_t).  */
  if (t == char_type_node
  || t == signed_char_type_node
  || t == unsigned_char_type_node)
return 0;

Which appears to be wrong, so I'm adjusting that as well.

PR c/111884

gcc/c-family/ChangeLog:

* c-common.cc (c_common_get_alias_set): Return -1 for char8_t only
in C++.

gcc/testsuite/ChangeLog:

* c-c++-common/alias-1.c: New test.

[Bug c/111884] [13/14 Regression] unsigned char no longer aliases anything under -std=c2x

2023-10-20 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111884

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c/111884] [13/14 Regression] unsigned char no longer aliases anything under -std=c2x

2023-10-19 Thread tom at honermann dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111884

--- Comment #4 from Tom Honermann  ---
(In reply to Marek Polacek from comment #3)
> Thanks, I can test

Thank you. That change looks right. My apologies for introducing the
regression.

[Bug c/111884] [13/14 Regression] unsigned char no longer aliases anything under -std=c2x

2023-10-19 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111884

Andrew Pinski  changed:

   What|Removed |Added

Summary|unsigned char no longer |[13/14 Regression] unsigned
   |aliases anything under  |char no longer aliases
   |-std=c2x|anything under -std=c2x
   Keywords||diagnostic
   Target Milestone|--- |13.3