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

            Bug ID: 109939
           Summary: Invalid return type for __builtin_arm_ssat: Unsigned
                    instead of signed
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dev at benjarobin dot fr
  Target Milestone: ---

The warning is triggered with the following test case:

```
int dbg_ssat_out;
int dbg_ssat_in;

void test_arm_ssat(void)
{
    dbg_ssat_out = __builtin_arm_ssat(dbg_ssat_in, 16);
}
```

Compile it using this command line:
arm-none-eabi-gcc -mcpu=cortex-m4 -Wall -Wconversion -c t.c -o t.o

The following output is generated:
```
t.c: In function 'test_arm_ssat':
t.c:7:20: warning: conversion to 'int' from 'unsigned int' may change the sign
of the result [-Wsign-conversion]
    7 |     dbg_ssat_out = __builtin_arm_ssat(dbg_ssat_in, 16);
      |                    ^~~~~~~~~~~~~~~~~~
```

This is an issue since SSAT assembly instruction returns a signed value and not
an unsigned integer.

Maybe this line is wrong (I am not an expert about GCC):
https://github.com/gcc-mirror/gcc/blob/releases/gcc-13.1.0/gcc/config/arm/arm-builtins.cc#L100

Reply via email to