[cmake-developers] [CMake 0014314]: GCC warns about strict aliasing in cm_sha2.c
Mantis Bug Tracker
mantis at public.kitware.com
Thu Jul 25 12:17:15 EDT 2013
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=14314
======================================================================
Reported By: Petr Machata
Assigned To:
======================================================================
Project: CMake
Issue ID: 14314
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2013-07-25 12:17 EDT
Last Modified: 2013-07-25 12:17 EDT
======================================================================
Summary: GCC warns about strict aliasing in cm_sha2.c
Description:
When compiling cm_sha2.c, GCC gives the following warning:
/builddir/build/BUILD/cmake-2.8.11.2/Source/cm_sha2.c: In function
'cmSHA1_Final':
/builddir/build/BUILD/cmake-2.8.11.2/Source/cm_sha2.c:743:2: warning:
dereferencing type-punned pointer will break strict-aliasing rules
[-Wstrict-aliasing]
*(sha_word64*)&context->s1.buffer[56] = context->s1.bitcount;
^
There are four cases total.
Steps to Reproduce:
1) Compile with recent GCC (4.8?)
2) Inspect compile log
Additional Information:
I propose fixing this by copying the necessary bytes through union. This should
lead to the same binary, but will make it clear to GCC that we are only using
the buffer as a bunch of characters. The test suite passes after applying the
patch, that I attach.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2013-07-25 12:17 Petr Machata New Issue
2013-07-25 12:17 Petr Machata File Added: cmake-2.8.11-strict_aliasing.patch
======================================================================
More information about the cmake-developers
mailing list