public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dev at benjarobin dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/109939] New: Invalid return type for __builtin_arm_ssat: Unsigned instead of signed
Date: Tue, 23 May 2023 08:06:00 +0000	[thread overview]
Message-ID: <bug-109939-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2023-05-23  8:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23  8:06 dev at benjarobin dot fr [this message]
2023-05-23  8:13 ` [Bug target/109939] " pinskia at gcc dot gnu.org
2023-05-23  8:21 ` dev at benjarobin dot fr
2023-05-23  8:52 ` ktkachov at gcc dot gnu.org
2023-05-24  8:33 ` cvs-commit at gcc dot gnu.org
2023-05-24  8:35 ` ktkachov at gcc dot gnu.org
2023-06-08  8:31 ` cvs-commit at gcc dot gnu.org
2023-06-08  8:54 ` cvs-commit at gcc dot gnu.org
2024-06-04 12:49 ` ktkachov at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109939-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).