Insert an explicit cast for -Wc++11-narrowing error #181

Merged
MicheleC merged 1 commits from fix/add_static_cast into master 1 year ago
Ray-V commented 1 year ago
Collaborator

Building with gcc 11.2.0 or clang 13.0.1
64 bit builds are ok with gcc or clang.
For a 32 bit build, with gcc is ok, but with clang, this failure occurs:

/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:9: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__time_t' (aka 'long') in initializer list [-Wc++11-narrowing]
      { i_ms / 1000, (i_ms % 1000) * 1000 },
        ^~~~~~~~~~~
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:9: note: insert an explicit cast to silence this issue
      { i_ms / 1000, (i_ms % 1000) * 1000 },
        ^~~~~~~~~~~
        static_cast<__time_t>( )
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:22: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__suseconds_t' (aka 'long') in initializer list [-Wc++11-narrowing]
      { i_ms / 1000, (i_ms % 1000) * 1000 },
                     ^~~~~~~~~~~~~~~~~~~~
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:22: note: insert an explicit cast to silence this issue
      { i_ms / 1000, (i_ms % 1000) * 1000 },
                     ^~~~~~~~~~~~~~~~~~~~
                     static_cast<__suseconds_t>( )
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:9: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__time_t' (aka 'long') in initializer list [-Wc++11-narrowing]
      { ms / 1000, (ms % 1000) * 1000 }
        ^~~~~~~~~
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:9: note: insert an explicit cast to silence this issue
      { ms / 1000, (ms % 1000) * 1000 }
        ^~~~~~~~~
        static_cast<__time_t>( )
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:20: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__suseconds_t' (aka 'long') in initializer list [-Wc++11-narrowing]
      { ms / 1000, (ms % 1000) * 1000 }
                   ^~~~~~~~~~~~~~~~~~
/tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:20: note: insert an explicit cast to silence this issue
      { ms / 1000, (ms % 1000) * 1000 }
                   ^~~~~~~~~~~~~~~~~~
                   static_cast<__suseconds_t>( )
4 errors generated.

32 bit builds are done in a chroot in the 64 bit host, hence with a 64 bit kernel.
64 bit builds are also done in a chroot.

Patching as proposed in the error message allows the 32 bit build to complete.
The 64 bit build with the patch is ok.

Building with gcc 11.2.0 or clang 13.0.1 64 bit builds are ok with gcc or clang. For a 32 bit build, with gcc is ok, but with clang, this failure occurs: ``` /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:9: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__time_t' (aka 'long') in initializer list [-Wc++11-narrowing] { i_ms / 1000, (i_ms % 1000) * 1000 }, ^~~~~~~~~~~ /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:9: note: insert an explicit cast to silence this issue { i_ms / 1000, (i_ms % 1000) * 1000 }, ^~~~~~~~~~~ static_cast<__time_t>( ) /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:22: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__suseconds_t' (aka 'long') in initializer list [-Wc++11-narrowing] { i_ms / 1000, (i_ms % 1000) * 1000 }, ^~~~~~~~~~~~~~~~~~~~ /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:390:22: note: insert an explicit cast to silence this issue { i_ms / 1000, (i_ms % 1000) * 1000 }, ^~~~~~~~~~~~~~~~~~~~ static_cast<__suseconds_t>( ) /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:9: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__time_t' (aka 'long') in initializer list [-Wc++11-narrowing] { ms / 1000, (ms % 1000) * 1000 } ^~~~~~~~~ /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:9: note: insert an explicit cast to silence this issue { ms / 1000, (ms % 1000) * 1000 } ^~~~~~~~~ static_cast<__time_t>( ) /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:20: error: non-constant-expression cannot be narrowed from type 'unsigned int' to '__suseconds_t' (aka 'long') in initializer list [-Wc++11-narrowing] { ms / 1000, (ms % 1000) * 1000 } ^~~~~~~~~~~~~~~~~~ /tmp/build/tmp-tdelibs/tdelibs-trinity-14.0.13/tdehtml/ecma/kjs_proxy.cpp:391:20: note: insert an explicit cast to silence this issue { ms / 1000, (ms % 1000) * 1000 } ^~~~~~~~~~~~~~~~~~ static_cast<__suseconds_t>( ) 4 errors generated. ``` 32 bit builds are done in a chroot in the 64 bit host, hence with a 64 bit kernel. 64 bit builds are also done in a chroot. Patching as proposed in the error message allows the 32 bit build to complete. The 64 bit build with the patch is ok.
Ray-V added 1 commit 1 year ago
856ba6b472
Insert an explicit cast for -Wc++11-narrowing error
MicheleC added this to the R14.1.0 release milestone 1 year ago
MicheleC approved these changes 1 year ago
MicheleC left a comment
Owner

Looks good, thanks.

Looks good, thanks.
MicheleC merged commit 856ba6b472 into master 1 year ago
MicheleC deleted branch fix/add_static_cast 1 year ago

Reviewers

MicheleC approved these changes 1 year ago
The pull request has been merged as 856ba6b472.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: TDE/tdelibs#181
Loading…
There is no content yet.