public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield
@ 2023-03-10 21:52 gcc at jonathanmueller dot dev
2023-03-10 22:04 ` [Bug c++/109096] " gcc at jonathanmueller dot dev
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: gcc at jonathanmueller dot dev @ 2023-03-10 21:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
Bug ID: 109096
Summary: __has_unique_object_representations does not account
for unnamed bitfield
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc at jonathanmueller dot dev
Target Milestone: ---
__has_unique_object_representations should return false for types that contain
an unnamed bit field of non-zero bit-width, since that introduces padding bits;
yet it doesn't:
```
#include <cassert>
#include <cstring>
struct foo
{
int member : 8;
// We explitly introduce 24 padding bits here.
int : 24;
bool operator==(const foo&) const = default;
};
// Yet this assertion passes?!
static_assert(__has_unique_object_representations(foo));
// But we clearly don't have unique object representations:
int main()
{
// Create two objects with different object representations.
foo a, b;
std::memset(&a, 0xFF, sizeof(foo));
std::memset(&b, 0x99, sizeof(foo));
// Make all members identical to give them the same value representation.
a.member = 0;
b.member = 0;
// This passes; they have the same value representation.
assert(a == b);
// But this fails; they don't have unique object representations!
assert(std::memcmp(&a, &b, sizeof(foo)) == 0);
}
```
https://godbolt.org/z/Y4GzqYE8s
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
@ 2023-03-10 22:04 ` gcc at jonathanmueller dot dev
2023-03-10 22:21 ` pinskia at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: gcc at jonathanmueller dot dev @ 2023-03-10 22:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #1 from Jonathan Müller <gcc at jonathanmueller dot dev> ---
Sorry, wrong godbolt link: https://godbolt.org/z/f1fGExsr7
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
2023-03-10 22:04 ` [Bug c++/109096] " gcc at jonathanmueller dot dev
@ 2023-03-10 22:21 ` pinskia at gcc dot gnu.org
2023-03-10 22:49 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-10 22:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-03-10
Ever confirmed|0 |1
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
2023-03-10 22:04 ` [Bug c++/109096] " gcc at jonathanmueller dot dev
2023-03-10 22:21 ` pinskia at gcc dot gnu.org
@ 2023-03-10 22:49 ` jakub at gcc dot gnu.org
2023-03-13 10:03 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-10 22:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |jakub at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (2 preceding siblings ...)
2023-03-10 22:49 ` jakub at gcc dot gnu.org
@ 2023-03-13 10:03 ` jakub at gcc dot gnu.org
2023-03-14 15:19 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-13 10:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54647
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54647&action=edit
gcc13-pr109096.patch
Untested fix.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (3 preceding siblings ...)
2023-03-13 10:03 ` jakub at gcc dot gnu.org
@ 2023-03-14 15:19 ` cvs-commit at gcc dot gnu.org
2023-03-14 15:20 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:c35cf160a0ed81570cff6600dba465cf95fa80fa
commit r13-6663-gc35cf160a0ed81570cff6600dba465cf95fa80fa
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 14 16:17:32 2023 +0100
c++: Treat unnamed bitfields as padding for
__has_unique_object_representations [PR109096]
As reported in the PR, for __has_unique_object_representations we
were treating unnamed bitfields as named ones, which is wrong, they
are actually padding.
THe following patch fixes that.
2023-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/109096
* tree.cc (record_has_unique_obj_representations): Ignore unnamed
bitfields.
* g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (4 preceding siblings ...)
2023-03-14 15:19 ` cvs-commit at gcc dot gnu.org
@ 2023-03-14 15:20 ` jakub at gcc dot gnu.org
2023-03-19 5:31 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-14 15:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (5 preceding siblings ...)
2023-03-14 15:20 ` jakub at gcc dot gnu.org
@ 2023-03-19 5:31 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:30 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-19 5:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:9dc438900f77cf47e4e89522bc68c85b289dd52a
commit r12-9290-g9dc438900f77cf47e4e89522bc68c85b289dd52a
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 14 16:17:32 2023 +0100
c++: Treat unnamed bitfields as padding for
__has_unique_object_representations [PR109096]
As reported in the PR, for __has_unique_object_representations we
were treating unnamed bitfields as named ones, which is wrong, they
are actually padding.
THe following patch fixes that.
2023-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/109096
* tree.cc (record_has_unique_obj_representations): Ignore unnamed
bitfields.
* g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
(cherry picked from commit c35cf160a0ed81570cff6600dba465cf95fa80fa)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (6 preceding siblings ...)
2023-03-19 5:31 ` cvs-commit at gcc dot gnu.org
@ 2023-03-20 10:30 ` jakub at gcc dot gnu.org
2023-05-02 20:15 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-20 10:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 12.3 too.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (7 preceding siblings ...)
2023-03-20 10:30 ` jakub at gcc dot gnu.org
@ 2023-05-02 20:15 ` cvs-commit at gcc dot gnu.org
2023-05-03 10:43 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-02 20:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:66d35a0cb88f83f085b2ba4c46d0429ba0cfe574
commit r11-10724-g66d35a0cb88f83f085b2ba4c46d0429ba0cfe574
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 14 16:17:32 2023 +0100
c++: Treat unnamed bitfields as padding for
__has_unique_object_representations [PR109096]
As reported in the PR, for __has_unique_object_representations we
were treating unnamed bitfields as named ones, which is wrong, they
are actually padding.
THe following patch fixes that.
2023-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/109096
* tree.c (record_has_unique_obj_representations): Ignore unnamed
bitfields.
* g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
(cherry picked from commit c35cf160a0ed81570cff6600dba465cf95fa80fa)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (8 preceding siblings ...)
2023-05-02 20:15 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03 10:43 ` jakub at gcc dot gnu.org
2023-05-03 15:22 ` cvs-commit at gcc dot gnu.org
2023-05-04 7:25 ` jakub at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-03 10:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.4 as well.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (9 preceding siblings ...)
2023-05-03 10:43 ` jakub at gcc dot gnu.org
@ 2023-05-03 15:22 ` cvs-commit at gcc dot gnu.org
2023-05-04 7:25 ` jakub at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 15:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:066de3a9bb2bc796cfc02767ab4d4440660f7086
commit r10-11377-g066de3a9bb2bc796cfc02767ab4d4440660f7086
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 14 16:17:32 2023 +0100
c++: Treat unnamed bitfields as padding for
__has_unique_object_representations [PR109096]
As reported in the PR, for __has_unique_object_representations we
were treating unnamed bitfields as named ones, which is wrong, they
are actually padding.
THe following patch fixes that.
2023-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/109096
* tree.c (record_has_unique_obj_representations): Ignore unnamed
bitfields.
* g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
(cherry picked from commit c35cf160a0ed81570cff6600dba465cf95fa80fa)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/109096] __has_unique_object_representations does not account for unnamed bitfield
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
` (10 preceding siblings ...)
2023-05-03 15:22 ` cvs-commit at gcc dot gnu.org
@ 2023-05-04 7:25 ` jakub at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-04 7:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.5 too.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-05-04 7:25 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 21:52 [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield gcc at jonathanmueller dot dev
2023-03-10 22:04 ` [Bug c++/109096] " gcc at jonathanmueller dot dev
2023-03-10 22:21 ` pinskia at gcc dot gnu.org
2023-03-10 22:49 ` jakub at gcc dot gnu.org
2023-03-13 10:03 ` jakub at gcc dot gnu.org
2023-03-14 15:19 ` cvs-commit at gcc dot gnu.org
2023-03-14 15:20 ` jakub at gcc dot gnu.org
2023-03-19 5:31 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:30 ` jakub at gcc dot gnu.org
2023-05-02 20:15 ` cvs-commit at gcc dot gnu.org
2023-05-03 10:43 ` jakub at gcc dot gnu.org
2023-05-03 15:22 ` cvs-commit at gcc dot gnu.org
2023-05-04 7:25 ` jakub 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).