public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115157] New: incorrect TBAA for derived types involving enum types
@ 2024-05-19 16:36 muecker at gwdg dot de
2024-05-19 21:45 ` [Bug tree-optimization/115157] " uecker at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: muecker at gwdg dot de @ 2024-05-19 16:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115157
Bug ID: 115157
Summary: incorrect TBAA for derived types involving enum types
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: muecker at gwdg dot de
Target Milestone: ---
Another example where TBAA does not seem to work correctly similar to PR114959.
I guess here it should be easier to set TYPE_CANONICAL correctly in the FE, but
we have the same completion issues we also have in C23 with other tagged types.
https://godbolt.org/z/qcWxn9f6z
enum E { E1 = -1, E2 = 0, E3 = 1 };
typedef int A;
typedef enum E B;
_Static_assert(_Generic((A){ 0 }, B: 1), "");
void* foo(void* a, void *b, A *c, B *d)
{
*(A**)a = c;
*(B**)b = d;
return *(A**)a;
}
int main()
{
A *a, b, c;
if (&c != (A*)foo(&a, &a, &b, &c))
__builtin_abort();
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/115157] incorrect TBAA for derived types involving enum types
2024-05-19 16:36 [Bug tree-optimization/115157] New: incorrect TBAA for derived types involving enum types muecker at gwdg dot de
@ 2024-05-19 21:45 ` uecker at gcc dot gnu.org
2024-05-26 12:21 ` muecker at gwdg dot de
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: uecker at gcc dot gnu.org @ 2024-05-19 21:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115157
uecker at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |uecker at gcc dot gnu.org
--- Comment #1 from uecker at gcc dot gnu.org ---
Created attachment 58246
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58246&action=edit
patch
Candidate patch by setting TYPE_CANONICAL based on the underlying type.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/115157] incorrect TBAA for derived types involving enum types
2024-05-19 16:36 [Bug tree-optimization/115157] New: incorrect TBAA for derived types involving enum types muecker at gwdg dot de
2024-05-19 21:45 ` [Bug tree-optimization/115157] " uecker at gcc dot gnu.org
@ 2024-05-26 12:21 ` muecker at gwdg dot de
2024-05-31 5:12 ` cvs-commit at gcc dot gnu.org
2024-06-03 10:36 ` rearnsha at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: muecker at gwdg dot de @ 2024-05-26 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115157
--- Comment #2 from Martin Uecker <muecker at gwdg dot de> ---
PATCH: https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652669.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/115157] incorrect TBAA for derived types involving enum types
2024-05-19 16:36 [Bug tree-optimization/115157] New: incorrect TBAA for derived types involving enum types muecker at gwdg dot de
2024-05-19 21:45 ` [Bug tree-optimization/115157] " uecker at gcc dot gnu.org
2024-05-26 12:21 ` muecker at gwdg dot de
@ 2024-05-31 5:12 ` cvs-commit at gcc dot gnu.org
2024-06-03 10:36 ` rearnsha at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-31 5:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115157
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>:
https://gcc.gnu.org/g:867d1264fe71d4291194373d1a1c409cac97a597
commit r15-933-g867d1264fe71d4291194373d1a1c409cac97a597
Author: Martin Uecker <uecker@tugraz.at>
Date: Sun May 19 23:13:22 2024 +0200
C: allow aliasing of compatible types derived from enumeral types
[PR115157]
Aliasing of enumeral types with the underlying integer is now allowed
by setting the aliasing set to zero. But this does not allow aliasing
of derived types which are compatible as required by ISO C. Instead,
initially set structural equality. Then set TYPE_CANONICAL and update
pointers and main variants when the type is completed (as done for
structures and unions in C23).
PR tree-optimization/115157
PR tree-optimization/115177
gcc/c/
* c-decl.cc (shadow_tag-warned,parse_xref_tag,start_enum,
finish_enum): Set SET_TYPE_STRUCTURAL_EQUALITY / TYPE_CANONICAL.
* c-objc-common.cc (get_alias_set): Remove special case.
(get_aka_type): Add special case.
gcc/c-family/
* c-attribs.cc (handle_hardbool_attribute): Set TYPE_CANONICAL
for hardbools.
gcc/
* godump.cc (go_output_typedef): Use TYPE_MAIN_VARIANT instead
of TYPE_CANONICAL.
gcc/testsuite/
* gcc.dg/enum-alias-1.c: New test.
* gcc.dg/enum-alias-2.c: New test.
* gcc.dg/enum-alias-3.c: New test.
* gcc.dg/enum-alias-4.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/115157] incorrect TBAA for derived types involving enum types
2024-05-19 16:36 [Bug tree-optimization/115157] New: incorrect TBAA for derived types involving enum types muecker at gwdg dot de
` (2 preceding siblings ...)
2024-05-31 5:12 ` cvs-commit at gcc dot gnu.org
@ 2024-06-03 10:36 ` rearnsha at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2024-06-03 10:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115157
--- Comment #4 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
The tests in the last patch fail on arm-eabi. The tests assume that
sizeof(enum) == sizeof(int), which is not true if -fshort-enum is the default.
++++++++++++++++++++++++++++++++++++++++++++++++
+ Changes for ./gcc/testsuite/gcc/gcc.sum.sent +
++++++++++++++++++++++++++++++++++++++++++++++++
New tests that FAIL (6 tests):
arm-qemu/-mthumb: gcc: gcc.dg/enum-alias-1.c (test for excess errors)
arm-qemu/-mthumb: gcc: gcc.dg/enum-alias-2.c execution test
arm-qemu/-mthumb: gcc: gcc.dg/enum-alias-3.c execution test
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-03 10:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19 16:36 [Bug tree-optimization/115157] New: incorrect TBAA for derived types involving enum types muecker at gwdg dot de
2024-05-19 21:45 ` [Bug tree-optimization/115157] " uecker at gcc dot gnu.org
2024-05-26 12:21 ` muecker at gwdg dot de
2024-05-31 5:12 ` cvs-commit at gcc dot gnu.org
2024-06-03 10:36 ` rearnsha 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).