Invalid assembly is generated when using intel syntax

Bug #1560686 reported by Hubert
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-5 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Invalid assembly code is generated when intel syntax (-masm=intel) is used and there are any symbols of the same name as CPU register. For example:

int ST = 42;
int main() {
 return ST;
}

Will produce messages like:
/tmp/ccglHDgh.s: Assembler messages:
/tmp/ccglHDgh.s:21: Error: invalid use of register

The problem is that GCC will generate nonsense like that:
mov eax, DWORD PTR ST[rip]

In case of such trivial example, it is very easy to find what the problem is but it can be really tricky to find the cause in larger projects. I expect that the compiler should at least generate some clear warning that using such names can cause problems.

Revision history for this message
Matthias Klose (doko) wrote :

It is because ST is a register. To use -masm=intel, one should avoid
using registers, like st, rax, xmm0, .... as variables.

Changed in gcc-5 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.