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

            Bug ID: 122275
           Summary: `DFP_SET_ROUNDMODE` etc. pass wrong operand size on
                    i686-w64-mingw32
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lh_mouse at 126 dot com
  Target Milestone: ---

The x87 control word is `unsigned short` but DFP macros pass `unsigned int`:

```
#define DFP_SET_ROUNDMODE(round)                                        \
  do                                                                    \
    {                                                                   \
      unsigned int _cw;                                                 \
      __asm__ __volatile__ ("fnstcw\t%0" : "=m" (_cw));                 \
      _cw &= ~FP_RND_MASK;                                              \
      _cw |= round;                                                     \
      __asm__ __volatile__ ("fldcw\t%0" :: "m" (_cw));                  \
```


This is seen when building libgcc on i686-w64-mingw32 with `-masm=intel`:

```
make[3]: Entering directory
'/home/lh_mouse/GitHub/MINGW-packages/mingw-w64-gcc/src/build-MINGW32/i686-w64-mingw32/libgcc'
/home/lh_mouse/GitHub/MINGW-packages/mingw-w64-gcc/src/build-MINGW32/./gcc/xgcc
-B/home/lh_mouse/GitHub/MINGW-packages/mingw-w64-gcc/src/build-MINGW32/./gcc/
-L/mingw32/i686-w64-mingw32/lib -L/mingw32/lib -isystem
/mingw32/i686-w64-mingw32/include -isystem /mingw32/include
-B/mingw32/i686-w64-mingw32/bin/ -B/mingw32/i686-w64-mingw32/lib/ -isystem
/mingw32/i686-w64-mingw32/include -isystem
/mingw32/i686-w64-mingw32/sys-include   -fno-checking -g -march=pentium4
-mtune=generic -masm=intel -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2
-fstack-protector-strong -Wp,-D__USE_MINGW_ANSI_STDIO=1 -O2
-I../../../gcc/libgcc/../winsup/w32api/include -g -march=pentium4
-mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong
-Wp,-D__USE_MINGW_ANSI_STDIO=1 -DIN_GCC   -W -Wall -Wno-error=narrowing
-Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition  -isystem ./include   -g
-DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -I. -I. -I../.././gcc
-I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc
-I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/i386
-I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  
-o bid128_div.o -MT bid128_div.o -MD -MP -MF bid128_div.dep -c
../../../gcc/libgcc/config/libbid/bid128_div.c
{standard input}: Assembler messages:
{standard input}:7137: Error: operand size mismatch for `fnstcw'
{standard input}:7153: Error: operand size mismatch for `fnstcw'
{standard input}:7162: Error: operand size mismatch for `fldcw'
{standard input}:7375: Error: operand size mismatch for `fnstcw'
{standard input}:7387: Error: operand size mismatch for `fldcw'
{standard input}:7704: Error: operand size mismatch for `fnstcw'
{standard input}:7716: Error: operand size mismatch for `fldcw'
{standard input}:9210: Error: operand size mismatch for `fnstcw'
{standard input}:9222: Error: operand size mismatch for `fldcw'
{standard input}:9584: Error: operand size mismatch for `fnstcw'
{standard input}:9596: Error: operand size mismatch for `fldcw'
{standard input}:9684: Error: operand size mismatch for `fnstcw'
{standard input}:9696: Error: operand size mismatch for `fldcw'
{standard input}:9759: Error: operand size mismatch for `fnstcw'
{standard input}:9771: Error: operand size mismatch for `fldcw'
{standard input}:11142: Error: operand size mismatch for `fnstcw'
```

Reply via email to