public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code
@ 2020-06-12 10:47 teo.samarzija at gmail dot com
  2020-06-12 11:19 ` [Bug c/95652] " teo.samarzija at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: teo.samarzija at gmail dot com @ 2020-06-12 10:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

            Bug ID: 95652
           Summary: GCC 8.3.1 generates syntactically incorrect assembly
                    code
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: teo.samarzija at gmail dot com
  Target Milestone: ---

Hey, guys!

So, I think I've found a bug in GCC 8.3.1 that occurs on Linux. Here is a
simple test case:

int printf(const char*,...);

float eax;

int main() {
    eax=7;
    printf("%lf\n",eax);
}

When compiled with "gcc -masm=intel -o test test.c", I get the error messages:

/tmp/ccGiemfM.s: Assembler messages:
/tmp/ccGiemfM.s:20: Error: invalid use of register
/tmp/ccGiemfM.s:21: Error: invalid use of register

It appears as though GCC 8.3.1 generates syntactically incorrect assembly code
for that.
Possibly related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52554

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/95652] GCC 8.3.1 generates syntactically incorrect assembly code
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
@ 2020-06-12 11:19 ` teo.samarzija at gmail dot com
  2020-06-12 11:41 ` [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: teo.samarzija at gmail dot com @ 2020-06-12 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

--- Comment #1 from Teo Samarzija <teo.samarzija at gmail dot com> ---
Possibly related, "as --version" prints:

GNU assembler (GNU Binutils) 2.33.1
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-pc-linux-gnu'.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
  2020-06-12 11:19 ` [Bug c/95652] " teo.samarzija at gmail dot com
@ 2020-06-12 11:41 ` pinskia at gcc dot gnu.org
  2020-06-12 16:11 ` teo.samarzija at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-06-12 11:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|GCC 8.3.1 generates         |GCC 8.3.1 generates
                   |syntactically incorrect     |syntactically incorrect
                   |assembly code               |assembly code with
                   |                            |-masm=intel
         Depends on|                            |87986

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This looks closer to a dup of bug 87986.

Basically -masm=intel is not always working.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87986
[Bug 87986] Assembler errors w/ -masm=intel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
  2020-06-12 11:19 ` [Bug c/95652] " teo.samarzija at gmail dot com
  2020-06-12 11:41 ` [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel pinskia at gcc dot gnu.org
@ 2020-06-12 16:11 ` teo.samarzija at gmail dot com
  2020-06-12 19:16 ` ubizjak at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: teo.samarzija at gmail dot com @ 2020-06-12 16:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

--- Comment #3 from Teo Samarzija <teo.samarzija at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> This looks closer to a dup of bug 87986.
> 
> Basically -masm=intel is not always working.

When does it occur? Maybe we can determine when it can occur and warn about it?
As far I can tell, it occurs when you use a reserved word in assembly as the
name of the global variable, and only under Linux (not under Windows, since the
names of global variables on Windows get prepended '_').
Why exactly does GCC use such a different convention for Windows and Linux?
Perhaps you can change that.
Besides, how does CLANG compile that same code fine, also under Linux and with
"-masm=intel"? Maybe you can copy the way CLANG does that.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
                   ` (2 preceding siblings ...)
  2020-06-12 16:11 ` teo.samarzija at gmail dot com
@ 2020-06-12 19:16 ` ubizjak at gmail dot com
  2020-06-12 19:18 ` teo.samarzija at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2020-06-12 19:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Teo Samarzija from comment #3)
> Besides, how does CLANG compile that same code fine, also under Linux and
> with "-masm=intel"? Maybe you can copy the way CLANG does that.

Clang outputs:

        mov     dword ptr [rip + eax], 1088421888

which gld does't understand:

pr95652.s: Assembler messages:
pr95652.s:17: Error: `dword ptr [rip+eax]' is not a valid base/index expression

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
                   ` (3 preceding siblings ...)
  2020-06-12 19:16 ` ubizjak at gmail dot com
@ 2020-06-12 19:18 ` teo.samarzija at gmail dot com
  2020-06-12 19:22 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: teo.samarzija at gmail dot com @ 2020-06-12 19:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

--- Comment #5 from Teo Samarzija <teo.samarzija at gmail dot com> ---
(In reply to Uroš Bizjak from comment #4)
> (In reply to Teo Samarzija from comment #3)
> > Besides, how does CLANG compile that same code fine, also under Linux and
> > with "-masm=intel"? Maybe you can copy the way CLANG does that.
> 
> Clang outputs:
> 
> 	mov	dword ptr [rip + eax], 1088421888
> 
> which gld does't understand:
> 
> pr95652.s: Assembler messages:
> pr95652.s:17: Error: `dword ptr [rip+eax]' is not a valid base/index
> expression

Which version of CLANG? CLANG 9.0 compiles the code in the opening post
correctly (under Linux and using Intel Syntax).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
                   ` (4 preceding siblings ...)
  2020-06-12 19:18 ` teo.samarzija at gmail dot com
@ 2020-06-12 19:22 ` ubizjak at gmail dot com
  2020-12-31 15:08 ` hjl.tools at gmail dot com
  2020-12-31 15:08 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2020-06-12 19:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Teo Samarzija from comment #5)
> (In reply to Uroš Bizjak from comment #4)
> > (In reply to Teo Samarzija from comment #3)
> > > Besides, how does CLANG compile that same code fine, also under Linux and
> > > with "-masm=intel"? Maybe you can copy the way CLANG does that.
> > 
> > Clang outputs:
> > 
> > 	mov	dword ptr [rip + eax], 1088421888
> > 
> > which gld does't understand:
> > 
> > pr95652.s: Assembler messages:
> > pr95652.s:17: Error: `dword ptr [rip+eax]' is not a valid base/index
> > expression
> 
> Which version of CLANG? CLANG 9.0 compiles the code in the opening post
> correctly (under Linux and using Intel Syntax).

Try to assemble the produced assembly with gas.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
                   ` (5 preceding siblings ...)
  2020-06-12 19:22 ` ubizjak at gmail dot com
@ 2020-12-31 15:08 ` hjl.tools at gmail dot com
  2020-12-31 15:08 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-31 15:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652
Bug 95652 depends on bug 87986, which changed state.

Bug 87986 Summary: Assembler errors w/ -masm=intel
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87986

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel
  2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
                   ` (6 preceding siblings ...)
  2020-12-31 15:08 ` hjl.tools at gmail dot com
@ 2020-12-31 15:08 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-31 15:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95652

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
dup.

*** This bug has been marked as a duplicate of bug 53929 ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-12-31 15:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 10:47 [Bug c/95652] New: GCC 8.3.1 generates syntactically incorrect assembly code teo.samarzija at gmail dot com
2020-06-12 11:19 ` [Bug c/95652] " teo.samarzija at gmail dot com
2020-06-12 11:41 ` [Bug target/95652] GCC 8.3.1 generates syntactically incorrect assembly code with -masm=intel pinskia at gcc dot gnu.org
2020-06-12 16:11 ` teo.samarzija at gmail dot com
2020-06-12 19:16 ` ubizjak at gmail dot com
2020-06-12 19:18 ` teo.samarzija at gmail dot com
2020-06-12 19:22 ` ubizjak at gmail dot com
2020-12-31 15:08 ` hjl.tools at gmail dot com
2020-12-31 15:08 ` hjl.tools at gmail dot com

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).