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

            Bug ID: 104804
           Summary: [12.0] x86_64 Extended asm always failed with "+=m" in
                    Output Operands and wrong error info
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 570070308 at qq dot com
  Target Milestone: ---

When using "+&m" in the Output Operands, the compile will always failed,
however, the "+&r" is ok.

And the error info seen to be wrong:
```
error: input operand constraint contains ‘&’
```
It is the onput operand constraint not input.


test2.c:
```
ig@ig-virtual-machine:~/temp$ cat test2.c
int main()
{
    char a, b;
    __asm__
        (
         "\n"
         :"+&m"( a )
         :"r"( b )
         :"cc"
         );
    return 0;
}
ig@ig-virtual-machine:~/temp$
```
compile error log:
```
ig@ig-virtual-machine:~/temp$ gcc-12 test2.c -S  -v
Using built-in specs.
COLLECT_GCC=gcc-12
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
12-20220302-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-VlTCdr/gcc-12-12-20220302/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-VlTCdr/gcc-12-12-20220302/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220302 (experimental) [master r12-7448-g58394373a70]
(Ubuntu 12-20220302-1ubuntu1) 
COLLECT_GCC_OPTIONS='-S' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/12/cc1 -quiet -v -imultiarch x86_64-linux-gnu
test2.c -quiet -dumpbase test2.c -dumpbase-ext .c -mtune=generic -march=x86-64
-version -o test2.s -fasynchronous-unwind-tables -fstack-protector-strong
-Wformat -Wformat-security -fstack-clash-protection -fcf-protection
GNU C17 (Ubuntu 12-20220302-1ubuntu1) version 12.0.1 20220302 (experimental)
[master r12-7448-g58394373a70] (x86_64-linux-gnu)
        compiled by GNU C version 12.0.1 20220302 (experimental) [master
r12-7448-g58394373a70], GMP version 6.2.1, MPFR version 4.1.0, MPC version
1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/12/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/12/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C17 (Ubuntu 12-20220302-1ubuntu1) version 12.0.1 20220302 (experimental)
[master r12-7448-g58394373a70] (x86_64-linux-gnu)
        compiled by GNU C version 12.0.1 20220302 (experimental) [master
r12-7448-g58394373a70], GMP version 6.2.1, MPFR version 4.1.0, MPC version
1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3929bb57dd80f5cc2d4f3202c349e2dc
test2.c: In function ‘main’:
test2.c:4:5: error: input operand constraint contains ‘&’
    4 |     __asm__
      |     ^~~~~~~
ig@ig-virtual-machine:~/temp$
```

and this is ok:
```
int main()
{
    char a, b;
    __asm__
        (
         "\n"
         :"+&r"( a )
         :"r"( b )
         :"cc"
         );
    return 0;
}
```

the gcc is installed by apt on ubuntu 22.04

Reply via email to