public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109726] New: use of variables whose name happen to match register names or keywords
@ 2023-05-04 4:11 lh_mouse at 126 dot com
2023-05-04 4:20 ` [Bug target/109726] use of variables whose name happen to match register names or keywords with -masm=intel pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: lh_mouse at 126 dot com @ 2023-05-04 4:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109726
Bug ID: 109726
Summary: use of variables whose name happen to match register
names or keywords
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: lh_mouse at 126 dot com
Target Milestone: ---
GAS PR: https://sourceware.org/bugzilla/show_bug.cgi?id=30418
Filed in both places, as we need changes both.
This is how MSVC handles such names:
(https://gcc.godbolt.org/z/TonjYaxqj)
```
static int* volatile rip;
static unsigned int volatile eax;
int
get_value(void)
{
return rip[eax];
}
```
MSVC outputs:
```
get_value PROC ; COMDAT
mov ecx, DWORD PTR eax
mov rax, QWORD PTR rip
mov eax, DWORD PTR [rax+rcx*4]
ret 0
get_value ENDP
```
GCC outputs:
```
get_value:
mov rdx, QWORD PTR rip[rip]
mov eax, DWORD PTR eax[rip]
mov eax, DWORD PTR [rdx+rax*4]
ret
```
In the case of MSVC, `DWORD PTR eax` is unambiguously parsed as the label `eax`
and `DWORD PTR [eax]` is unambiguously parsed as the register `eax`. The
address of all labels are always relative to RIP, but it is implied, and
brackets are not written explicitly.
Maybe GCC can follow MSVC to omit the RIP register and brackets. The x86_64
memory reference syntax matches x86 with the only change in semantics of the
immediate offset (for x86_64 it is relative to the next instruction, while for
i686 it is absolute), but the opcode is the same.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug target/109726] use of variables whose name happen to match register names or keywords with -masm=intel
2023-05-04 4:11 [Bug target/109726] New: use of variables whose name happen to match register names or keywords lh_mouse at 126 dot com
@ 2023-05-04 4:20 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-04 4:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109726
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 53929.
*** This bug has been marked as a duplicate of bug 53929 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-04 4:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 4:11 [Bug target/109726] New: use of variables whose name happen to match register names or keywords lh_mouse at 126 dot com
2023-05-04 4:20 ` [Bug target/109726] use of variables whose name happen to match register names or keywords with -masm=intel pinskia 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).