Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 719790

Summary: app-admin/procinfo-ng-2.0.304-r1 -- clang: ./lib/timeRoutines.cpp:134:38: error: non-constant-expression cannot be narrowed from type 'uint32_t' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing]
Product: Gentoo Linux Reporter: Frederik Pfautsch <bugs>
Component: Current packagesAssignee: Gentoo Shell Tools project <shell-tools>
Status: RESOLVED FIXED    
Severity: normal CC: bugs, jstein
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Compile log procinfo
emerge info

Description Frederik Pfautsch 2020-04-27 11:57:59 UTC
Created attachment 634848 [details]
Compile log procinfo

From the compile log:

<...>
./lib/timeRoutines.cpp:134:38: error: non-constant-expression cannot be narrowed from type 'uint32_t' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing]
                { tm_sec: result1.seconds, tm_min: result1.minutes, tm_hour: result1.hours,
                                                   ^~~~~~~~~~~~~~~
./lib/timeRoutines.cpp:134:38: note: insert an explicit cast to silence this issue
                { tm_sec: result1.seconds, tm_min: result1.minutes, tm_hour: result1.hours,
                                                   ^~~~~~~~~~~~~~~
                                                   static_cast<int>( )
./lib/timeRoutines.cpp:134:64: error: non-constant-expression cannot be narrowed from type 'uint32_t' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing]
                { tm_sec: result1.seconds, tm_min: result1.minutes, tm_hour: result1.hours,
                                                                             ^~~~~~~~~~~~~
./lib/timeRoutines.cpp:134:64: note: insert an explicit cast to silence this issue
                { tm_sec: result1.seconds, tm_min: result1.minutes, tm_hour: result1.hours,
                                                                             ^~~~~~~~~~~~~
                                                                             static_cast<int>( )
./lib/timeRoutines.cpp:135:12: error: non-constant-expression cannot be narrowed from type 'uint32_t' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing]
                tm_wday: result1.days, tm_week: result1.weeks };
                         ^~~~~~~~~~~~
./lib/timeRoutines.cpp:135:12: note: insert an explicit cast to silence this issue
                tm_wday: result1.days, tm_week: result1.weeks };
                         ^~~~~~~~~~~~
                         static_cast<int>( )
./lib/timeRoutines.cpp:135:35: error: non-constant-expression cannot be narrowed from type 'uint32_t' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing]
                tm_wday: result1.days, tm_week: result1.weeks };
<...>

Builds fine when using gcc instead of clang.

clang --version:
clang version 9.0.1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/9/bin

gcc --version:
gcc (Gentoo 9.2.0-r2 p3) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
Comment 1 Frederik Pfautsch 2020-04-27 11:58:44 UTC
Created attachment 634850 [details]
emerge info
Comment 2 Larry the Git Cow gentoo-dev 2022-11-10 05:10:37 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a4ae230be03c2f8ab6ed0e2d53f431d5bd649dbb

commit a4ae230be03c2f8ab6ed0e2d53f431d5bd649dbb
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-11-10 04:57:16 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-11-10 05:09:21 +0000

    app-admin/procinfo-ng: fix build w/ clang, -Wformat-security
    
    It's a lazy fix but upstream is dead and surprisingly other
    distros still package this. Fix -Wformat-security while at it.
    
    Closes: https://bugs.gentoo.org/719790
    Signed-off-by: Sam James <sam@gentoo.org>

 .../files/procinfo-ng-2.0.304-wformat-security.patch    | 11 +++++++++++
 ...-2.0.304-r1.ebuild => procinfo-ng-2.0.304-r2.ebuild} | 17 +++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)