On Thursday, September 20, 2012 7:57:09 AM UTC-6, Marshall Clow wrote:
>
> On Sep 17, 2012, at 5:35 PM, Joseph Galbraith
> <[email protected]<javascript:>>
> wrote:
>
> > Building wake.cpp with clang and -std=c++11 -stdlib=libc++ generates
> errors do narrowing. I believe the following patch is the right way to fix
> these. Any chance of getting this applied (or something else that makes it
> build out of the box) ?
>
> This patch bothers me.
> I (think I) understand the problem, and the rationale for the fix.
>
> But there's some subversion of the type system going on here, and it might
> be better to fix that, rather than continue it.
>
> To summarize:
> int arr [] = {
> 0x12345678,
> 0x89ABCFEF
> };
>
> Both of the values in the array are actually unsigned, and have to be
> (implicitly) converted to int.
> When compiling for c++11, clang (rightly) complains that 0x89ABCFEF is
> bigger than the maximum number representable by an int.
>
> Changing the type of the array to "unsigned int" (or just unsigned)
> removes the compile-time error - but does it change the algorithm?
>
That was actually my first (and preferred) fix, until
I saw this comment right above the array:
// x and z were declared as "long" in Wheeler's paper, which is a signed
type. I don't know if that was intentional, but it's too late to change it
now. -- Wei 7/4/2010
I just read the comment more carefully and realized it is not
referring to the array… and changing the array to unsigned int
didn't break the validation tests.
It turns out that tt is xored with x (which is signed)
and then assigned to t, which is word32 (unsigned) ...
so I think it is okay to change tt to unsigned.
Attached is a version of the patch that changes the array
to unsigned int.
Thanks,
Joseph
>
> -- Marshall
>
> Marshall Clow Idio Software <mailto:[email protected] <javascript:>>
>
>
> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is
> promptly moderated down to (-1, Flamebait).
> -- Yu Suzuki
>
>
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
Index: wake.cpp
===================================================================
--- wake.cpp (revision 533)
+++ wake.cpp (working copy)
@@ -23,7 +23,7 @@
signed int x, z, p;
// x and z were declared as "long" in Wheeler's paper, which is a signed type. I don't know if that was intentional, but it's too late to change it now. -- Wei 7/4/2010
CRYPTOPP_COMPILE_ASSERT(sizeof(x) == 4);
- static int tt[10]= {
+ static unsigned int tt[10]= {
0x726a8f3b, // table
0xe69a3b5c,
0xd3c71fe5,