NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
toolchain/58728: lint objects to __SHIFTIN/__BITS of values in known-limited range without cast
>Number: 58728
>Category: toolchain
>Synopsis: lint objects to __SHIFTIN/__BITS of values in known-limited range without cast
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 08 13:05:01 +0000 2024
>Originator: Taylor R Campbell
>Release: current
>Organization:
The LintBSD Shiftination
>Environment:
>Description:
178 const char16_t w1 = S->surrogate;
179 const char16_t w2 = c16;
180 c32 = (char32_t)(
181 __SHIFTIN(__SHIFTOUT(w1, __BITS(9,0)), __BITS(19,10)) |
182 __SHIFTIN(__SHIFTOUT(w2, __BITS(9,0)), __BITS(9,0)));
https://nxr.netbsd.org/xref/src/lib/libc/locale/c16rtomb.c?r=1.7#178
Without this (char32_t) cast, lint objects:
/home/riastradh/netbsd/current/src/lib/libc/locale/c16rtomb.c(182): warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132]
But it should be statically obvious from a local range analysis that truncation is impossible here, so the cast is unnecessary.
>How-To-Repeat:
omit needless cast in lib/libc/locale/c16rtomb.c, make -C lib/libc lint
>Fix:
Yes, please!
Home |
Main Index |
Thread Index |
Old Index