Patch committed: Remove const qualifier which triggers C++ warning
Ian Lance Taylor
iant@google.com
Fri Jun 19 16:46:00 GMT 2009
This code in varasm.c const int shift = sizeof (hashval_t) * CHAR_BIT;
const int shift = sizeof (hashval_t) * CHAR_BIT;
const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
int i;
h ^= (hashval_t) hwi;
for (i = 1; i < n; ++i)
{
hwi >>= shift;
h ^= (hashval_t) hwi;
}
give a warnings when compiling with C++: the shift is too large for the
type. The invalid shift will never be executed, but the C++ frontend
can't see that. This does not give a warning with the C frontend
because the C frontend does not propagate the const in the parser. The
C++ frontend does, as is required by C++ const rules.
In practice the const qualifier does not help optimization, and removing
it avoids the C++ warning. That is what this patch does, rather than
doing anything more complicated.
Bootstrapped and tested on x86_64-unknown-linux-gnu. Committed.
Ian
2009-06-19 Ian Lance Taylor <iant@google.com>
* varasm.c (const_rtx_hash_1): Remove const qualifier from shift.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 421 bytes
Desc: Remove const qualifier
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090619/36c555de/attachment.bin>
More information about the Gcc-patches
mailing list