bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -fsanitize=undefined detects undefined behaviour in signed shift ove


From: Thomas Dickey
Subject: Re: -fsanitize=undefined detects undefined behaviour in signed shift overflow
Date: Sat, 8 May 2021 16:31:46 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Sat, May 08, 2021 at 08:55:48PM +0100, Sergei Trofimovich wrote:
> Hello ncurses maintainers!
> 
> In search for an unrelated bug I built a few local tools with
> `-fsanitize=undefined` gcc option to catch an suspected undefined
> behaviour.
> 
> Among other things ncurses was flagged in ncurses-based applications as:
>   ncurses/tinfo/read_entry.c:111:19:
>     runtime error: left shift of 255 by 24 places cannot be represented in 
> type 'int'
> 
> which looks like a real (perhaps minor) problem:

I'm aware of the warning, but don't see a way to detect the overflow
and not elicit a warning about undefined behavior.

A patch would help discussion.

(earlier this week I noticed a change by someone to eliminate undefined
behavior which doesn't produce a compiler warning with/without the change,
_and_ the change causes incorrect behavior -- something to keep in mind)

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]