Bug 1242980 - -Wcast-qual compiler warnings in hv_func.h
Summary: -Wcast-qual compiler warnings in hv_func.h
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: perl
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Pisar
QA Contact: Fedora Extras Quality Assurance
URL: https://rt.perl.org/Ticket/Display.ht...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-14 13:51 UTC by Jan Safranek
Modified: 2017-01-03 21:24 UTC (History)
9 users (show)

Fixed In Version: perl-5.24.0-381.fc26 perl-5.24.0-380.fc25 perl-5.22.2-365.fc24
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-22 05:24:26 UTC


Attachments (Terms of Use)

Description Jan Safranek 2015-07-14 13:51:03 UTC
I get following warnings when compiling net-snmp with -Wall:

gcc -c   -I../../include -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2 -Ulinux -Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/CORE -Wall -Wstrict-prototypes -Wwrite-strings -Wcast-qual -I. -I/usr/local/include -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic   -DVERSION=\"5.08\" -DXS_VERSION=\"5.08\" -fPIC "-I/usr/lib64/perl5/CORE"   default_store.c
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
                 from /usr/lib64/perl5/CORE/perl.h:3344,
                 from default_store.xs:6:
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_siphash_2_4’:
/usr/lib64/perl5/CORE/hv_func.h:201:23: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   U64TYPE k0 = ((U64TYPE*)seed)[0];
                       ^
/usr/lib64/perl5/CORE/hv_func.h:202:23: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   U64TYPE k1 = ((U64TYPE*)seed)[1];
                       ^
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
                 from /usr/lib64/perl5/CORE/perl.h:3344,
                 from default_store.xs:6:
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_superfast’:
/usr/lib64/perl5/CORE/hv_func.h:260:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 hash = *((U32*)seed) + len;
                  ^
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
                 from /usr/lib64/perl5/CORE/perl.h:3344,
                 from default_store.xs:6:
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_murmur3’:
/usr/lib64/perl5/CORE/hv_func.h:364:16: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 h1 = *((U32*)seed);
                ^
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
                 from /usr/lib64/perl5/CORE/perl.h:3344,
                 from default_store.xs:6:
/usr/lib64/perl5/CORE/hv_func.h:401:21: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
             k1 = U8TO32_LE(ptr);
                     ^
/usr/lib64/perl5/CORE/hv_func.h:408:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
             carry = U8TO32_LE(ptr);
                        ^
/usr/lib64/perl5/CORE/hv_func.h:416:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
             carry = U8TO32_LE(ptr);
                        ^
/usr/lib64/perl5/CORE/hv_func.h:424:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
             carry = U8TO32_LE(ptr);
                        ^
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_djb2’:
/usr/lib64/perl5/CORE/hv_func.h:458:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 hash = *((U32*)seed + len);
                  ^
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_sdbm’:
/usr/lib64/perl5/CORE/hv_func.h:468:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 hash = *((U32*)seed + len);
                  ^
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
                 from /usr/lib64/perl5/CORE/perl.h:3344,
                 from default_store.xs:6:
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_one_at_a_time’:
/usr/lib64/perl5/CORE/hv_func.h:494:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 hash = *((U32*)seed) + len;
                  ^
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_one_at_a_time_hard’:
/usr/lib64/perl5/CORE/hv_func.h:509:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 hash = *((U32*)seed) + len;
                  ^
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_old_one_at_a_time’:
/usr/lib64/perl5/CORE/hv_func.h:544:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     U32 hash = *((U32*)seed);
                  ^

This pollutes build logs and we may miss some useful warning. What about this?

-     U32 hash = *((U32*)seed) + len;
+     U32 hash = (U32) *seed + len;

Comment 1 Jan Kurik 2015-07-15 13:16:48 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 23 development cycle.
Changing version to '23'.

(As we did not run this process for some time, it could affect also pre-Fedora 23 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 23 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora23

Comment 2 Fedora End Of Life 2016-11-24 12:12:11 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Petr Pisar 2016-11-24 13:56:29 UTC
The proposed change is wrong. Original code copies 4 bytes from a memory specified by a pointer. Proposed code would take 1 byte from a memory specified by a pointer and coerced the value to a 4-byte integer.

But your point about the cast constness is valid.

Comment 4 Petr Pisar 2016-11-24 14:42:17 UTC
Reproducer:

$ printf '#include "EXTERN.h"\n#include "perl.h"\n' | gcc -Wcast-qual -I/usr/lib64/perl5/CORE -c -x c -
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
                 from /usr/lib64/perl5/CORE/perl.h:3740,
                 from <stdin>:2:
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_siphash_2_4’:
/usr/lib64/perl5/CORE/hv_func.h:213:17: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   U64TYPE k0 = ((U64TYPE*)seed)[0];
                 ^
et cetera.

Comment 5 Petr Pisar 2016-11-25 13:30:46 UTC
I developed fixes that are under review now. However upstream developmental code added new violating in-line functions that he does not to fix. So probably you will have to live with some warnings in the future.

Comment 6 Petr Pisar 2016-12-01 06:39:49 UTC
Upstream accepted the fixes. The new violations were fixed by suppressing the warnings.

Comment 7 Fedora Update System 2016-12-19 15:28:11 UTC
perl-5.24.0-380.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-213ba43154

Comment 8 Fedora Update System 2016-12-20 06:54:27 UTC
perl-5.22.2-365.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-85dffa754f

Comment 9 Fedora Update System 2016-12-20 09:23:51 UTC
perl-5.24.0-380.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-213ba43154

Comment 10 Fedora Update System 2016-12-20 19:21:52 UTC
perl-5.22.2-365.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-85dffa754f

Comment 11 Fedora Update System 2016-12-22 05:24:26 UTC
perl-5.24.0-380.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 12 Fedora Update System 2017-01-03 21:24:31 UTC
perl-5.22.2-365.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.