public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
@ 2024-04-11  9:00 dcb314 at hotmail dot com
  2024-04-11 10:35 ` [Bug libgcc/114689] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2024-04-11  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114689
           Summary: [14 Regression] libgcc/config/m68k/fpgnulib.c:305:
                    Suspicious coding ?
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Static analyser cppcheck says:

libgcc/config/m68k/fpgnulib.c:305:37: style: Boolean result is used in bitwise
operation. Clarify expression with parentheses. [clarifyCondition]

Source code is

     mant = mant >> 1 | (mant & 1) | !!sticky;

Perhaps

     mant = (mant >> 1) | (mant & 1) | !!sticky;

was intended. 

This problem doesn't exist in the source code of gcc-13.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
@ 2024-04-11 10:35 ` rguenth at gcc dot gnu.org
  2024-04-12  8:30 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-11 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |m68k
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
  2024-04-11 10:35 ` [Bug libgcc/114689] " rguenth at gcc dot gnu.org
@ 2024-04-12  8:30 ` jakub at gcc dot gnu.org
  2024-04-12 10:13 ` schwab@linux-m68k.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-12  8:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |keithp at keithp dot com,
                   |                            |law at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
mant = mant >> 1 | (mant & 1) | !!sticky;
is equivalent to
mant = (mant >> 1) | (mant & 1) | !!sticky;
I guess cppcheck is complaining on the | !!sticky part, but that feels
intentional too.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
  2024-04-11 10:35 ` [Bug libgcc/114689] " rguenth at gcc dot gnu.org
  2024-04-12  8:30 ` jakub at gcc dot gnu.org
@ 2024-04-12 10:13 ` schwab@linux-m68k.org
  2024-04-12 10:16 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab@linux-m68k.org @ 2024-04-12 10:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
Nevertheless it's better for clarity to parentize >> inside |.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2024-04-12 10:13 ` schwab@linux-m68k.org
@ 2024-04-12 10:16 ` jakub at gcc dot gnu.org
  2024-04-12 13:33 ` law at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-12 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But guess that won't shut up cppcheck, I'd think it wants | (!!sticky) instead
of
| !!sticky.  Haven't tried though.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2024-04-12 10:16 ` jakub at gcc dot gnu.org
@ 2024-04-12 13:33 ` law at gcc dot gnu.org
  2024-04-12 21:47 ` dcb314 at hotmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: law at gcc dot gnu.org @ 2024-04-12 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2024-04-12 13:33 ` law at gcc dot gnu.org
@ 2024-04-12 21:47 ` dcb314 at hotmail dot com
  2024-04-12 21:56 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2024-04-12 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
I tried this code:

extern void g( int);

void f( int mant, int sticky)
{
        mant = mant >> 1 ;
        mant = mant >> 1 | (mant & 1);
        mant = mant >> 1 | (mant & 1) | !!sticky;
        mant = !!sticky;
        mant = (mant & 1) | !!sticky;
        g( mant);
}

Cppcheck says:

$ ~/cppcheck/trunk/cppcheck --enable=all apr12a.cc
apr12a.cc:8:32: style: Boolean result is used in bitwise operation. Clarify
expression with parentheses. [clarifyCondition]
 mant = mant >> 1 | (mant & 1) | !!sticky;
                               ^
apr12a.cc:10:20: style: Boolean result is used in bitwise operation. Clarify
expression with parentheses. [clarifyCondition]
 mant = (mant & 1) | !!sticky;
                   ^
so it appears to be the combination of bitwise operation (mant & 1) 
and the boolean result !!sticky.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2024-04-12 21:47 ` dcb314 at hotmail dot com
@ 2024-04-12 21:56 ` jakub at gcc dot gnu.org
  2024-04-13  7:06 ` dcb314 at hotmail dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-12 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And does
extern void g( int);

void f( int mant, int sticky)
{
        mant = mant >> 1 ;
        mant = mant >> 1 | (mant & 1);
        mant = mant >> 1 | (mant & 1) | (!!sticky);
        mant = !!sticky;
        mant = (mant & 1) | (!!sticky);
        g( mant);
}
shut up those warnings?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2024-04-12 21:56 ` jakub at gcc dot gnu.org
@ 2024-04-13  7:06 ` dcb314 at hotmail dot com
  2024-04-15 15:46 ` cvs-commit at gcc dot gnu.org
  2024-04-15 15:48 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2024-04-13  7:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Jakub Jelinek from comment #5)
> And does
> extern void g( int);
> 
> void f( int mant, int sticky)
> {
> 	mant = mant >> 1 ;
> 	mant = mant >> 1 | (mant & 1);
> 	mant = mant >> 1 | (mant & 1) | (!!sticky);
> 	mant = !!sticky;
> 	mant = (mant & 1) | (!!sticky);
> 	g( mant);
> }
> shut up those warnings?

Yes.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (7 preceding siblings ...)
  2024-04-13  7:06 ` dcb314 at hotmail dot com
@ 2024-04-15 15:46 ` cvs-commit at gcc dot gnu.org
  2024-04-15 15:48 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-15 15:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:f8409c3109d2970a1fd63ac1a61601138b7ae46f

commit r14-9976-gf8409c3109d2970a1fd63ac1a61601138b7ae46f
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Apr 15 17:46:03 2024 +0200

    m68k: Quiet up cppcheck warning [PR114689]

    cppcheck apparently warns on the | !!sticky part of the expression and
    using | (!!sticky) quiets it up (it is correct as is).
    The following patch adds the ()s, and also adds them around mant >> 1 just
    in case it makes it clearer to all readers that the expression is parsed
    that way already.

    2024-04-15  Jakub Jelinek  <jakub@redhat.com>

            PR libgcc/114689
            * config/m68k/fpgnulib.c (__truncdfsf2): Add parentheses around
            !!sticky bitwise or operand to quiet up cppcheck.  Add parentheses
            around mant >> 1 bitwise or operand.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libgcc/114689] [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ?
  2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
                   ` (8 preceding siblings ...)
  2024-04-15 15:46 ` cvs-commit at gcc dot gnu.org
@ 2024-04-15 15:48 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-15 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be silenced now (am not saying fixed because there was no bug).

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-04-15 15:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11  9:00 [Bug libgcc/114689] New: [14 Regression] libgcc/config/m68k/fpgnulib.c:305: Suspicious coding ? dcb314 at hotmail dot com
2024-04-11 10:35 ` [Bug libgcc/114689] " rguenth at gcc dot gnu.org
2024-04-12  8:30 ` jakub at gcc dot gnu.org
2024-04-12 10:13 ` schwab@linux-m68k.org
2024-04-12 10:16 ` jakub at gcc dot gnu.org
2024-04-12 13:33 ` law at gcc dot gnu.org
2024-04-12 21:47 ` dcb314 at hotmail dot com
2024-04-12 21:56 ` jakub at gcc dot gnu.org
2024-04-13  7:06 ` dcb314 at hotmail dot com
2024-04-15 15:46 ` cvs-commit at gcc dot gnu.org
2024-04-15 15:48 ` jakub at gcc dot gnu.org

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).