[Bug middle-end/120803] New: inline assembly sign extends unsigned constraints
oskari.alaranta at bananymous dot com
gcc-bugzilla@gcc.gnu.org
Tue Jun 24 12:34:27 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120803
Bug ID: 120803
Summary: inline assembly sign extends unsigned constraints
Product: gcc
Version: 15.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: oskari.alaranta at bananymous dot com
Target Milestone: ---
Following code possibly incorrectly sign extends constexpr value passed to
inline assembly. Compiled with `g++ --std=c++20 -O2 -c foo.cpp`.
void foo() {
constexpr unsigned char value = 0x80;
asm("int %0" :: "i"(value));
}
Generated assembly for the int instruction is `int $-128` which fails to
assemble with message "Error: operand size mismatch for `int'".
I'm not sure if this is a bug in GCC or binutils. After updating from GCC
12.2.0->15.1.0 and binutils 2.39->2.44 my codebase fails to compile because of
this. GCC's behaviour has not changed, it used to produce `int $-128` even in
12.2.0 but binutils 2.39 accepted it.
Compiler configuration
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.1 20250425 (GCC)
More information about the Gcc-bugs
mailing list