public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
@ 2023-07-10 8:44 iains at gcc dot gnu.org
2023-07-10 8:48 ` [Bug target/110611] " iains at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: iains at gcc dot gnu.org @ 2023-07-10 8:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
Bug ID: 110611
Summary: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32
code.
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: iains at gcc dot gnu.org
Target Milestone: ---
I've made this target but not sure exactly where it lies - the gimplifier
output looks suspect already - so maybe it's gimplifer/frontend.
this code is distilled from a version of GDB (7.12) where 'bar' is a system
call that breaks with a sign-extended pointer...
the x86 backend sets:
gcc/config/i386/i386.h:#define POINTERS_EXTEND_UNSIGNED 1
which ought, according to gccint mean that pointers get sign-extended...
t.c ====
typedef unsigned long long uint64_t;
typedef uint64_t another_t;
typedef unsigned char byte;
extern void bar (another_t y, another_t z);
void foo (byte *p)
{
another_t x = (another_t)p;
bar ((another_t) p, x);
}
===
build : $(compiler) -m32 t.c -S -fdump-tree-gimple -Wall -Wextra
* If built by the GCC compiler, we get warnings like;
warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
9 | another_t x = (another_t)p;
* if built by G++ we get no warnings
However, in both cases, the generated assembler sign-extends *p => x and the
first arg to bar.
gimple:
void foo (byte * p)
{
another_t x;
p.0_1 = (int) p;
x = (another_t) p.0_1;
p.1_2 = (int) p;
_3 = (long long unsigned int) p.1_2;
bar (_3, x);
}
maybe the combination of 'perhaps wrong' user code, plus the maze of typedefs
is confusing something.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110611] X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
@ 2023-07-10 8:48 ` iains at gcc dot gnu.org
2023-07-10 8:49 ` iains at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: iains at gcc dot gnu.org @ 2023-07-10 8:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-linux-gnu,
| |x86_64-darwin, i686-darwin
Keywords| |wrong-code
Known to fail| |10.5.0, 14.0
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
Apple GCC-4.2.1 does zero-extend.
I checked back to 5.5 on Darwin the same issue is present to at least then.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110611] X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
2023-07-10 8:48 ` [Bug target/110611] " iains at gcc dot gnu.org
@ 2023-07-10 8:49 ` iains at gcc dot gnu.org
2023-07-10 9:03 ` schwab@linux-m68k.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: iains at gcc dot gnu.org @ 2023-07-10 8:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Iain Sandoe from comment #0)
> the x86 backend sets:
> gcc/config/i386/i386.h:#define POINTERS_EXTEND_UNSIGNED 1
> which ought, according to gccint mean that pointers get sign-extended...
erm I mean zero-extended:
POINTERS_EXTEND_UNSIGNED [Macro]
A C expression that determines how pointers should be extended from ptr_mode to
either Pmode or word_mode. It is greater than zero if pointers should be
zero-extended, zero if they should be sign-extended, and negative if some other
sort of conversion is needed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110611] X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
2023-07-10 8:48 ` [Bug target/110611] " iains at gcc dot gnu.org
2023-07-10 8:49 ` iains at gcc dot gnu.org
@ 2023-07-10 9:03 ` schwab@linux-m68k.org
2023-07-10 9:05 ` iains at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2023-07-10 9:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
uint64_t is neither Pmode nor word_mode here. POINTERS_EXTEND_UNSIGNED is only
relevant if POINTER_SIZE is narrower than Pmode.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110611] X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
` (2 preceding siblings ...)
2023-07-10 9:03 ` schwab@linux-m68k.org
@ 2023-07-10 9:05 ` iains at gcc dot gnu.org
2023-07-10 9:32 ` amonakov at gcc dot gnu.org
2023-07-10 9:33 ` iains at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: iains at gcc dot gnu.org @ 2023-07-10 9:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Andreas Schwab from comment #3)
> uint64_t is neither Pmode nor word_mode here. POINTERS_EXTEND_UNSIGNED is
> only relevant if POINTER_SIZE is narrower than Pmode.
So, just pilot-error, then?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110611] X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
` (3 preceding siblings ...)
2023-07-10 9:05 ` iains at gcc dot gnu.org
@ 2023-07-10 9:32 ` amonakov at gcc dot gnu.org
2023-07-10 9:33 ` iains at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-07-10 9:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #5 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
You cannot use this internal macro to deduce how your C testcase should behave.
The language standard says this conversion has implementation-defined behavior,
and GCC manual (the user manual, not the internals manual) has a chapter on
implementation-defined behavior, which explicitly says:
https://gcc.gnu.org/onlinedocs/gcc/Arrays-and-pointers-implementation.html
A cast from pointer to integer [...] sign-extends if the pointer representation
is smaller than the integer type [...].
So the behavior is the same for all targets.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110611] X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code.
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
` (4 preceding siblings ...)
2023-07-10 9:32 ` amonakov at gcc dot gnu.org
@ 2023-07-10 9:33 ` iains at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: iains at gcc dot gnu.org @ 2023-07-10 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110611
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
so just wrong code; OK.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-07-10 9:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10 8:44 [Bug target/110611] New: X86 is not honouring POINTERS_EXTEND_UNSIGNED in m32 code iains at gcc dot gnu.org
2023-07-10 8:48 ` [Bug target/110611] " iains at gcc dot gnu.org
2023-07-10 8:49 ` iains at gcc dot gnu.org
2023-07-10 9:03 ` schwab@linux-m68k.org
2023-07-10 9:05 ` iains at gcc dot gnu.org
2023-07-10 9:32 ` amonakov at gcc dot gnu.org
2023-07-10 9:33 ` iains 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).