Severed bunny head
User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Special Interest > Eternity > VC++ compile warnings
 
Author
All times are GMT. The time now is 10:02. Post New Thread    Post A Reply
Gez
Why don't I have a custom title by now?!


Posts: 12524
Registered: 07-07


These three warnings have been there for a while, so I suppose that maybe GCC doesn't catch them. They're all instances of purposefully exploiting 32-bit math overflow on angle_t values.
code:
1>.\source\r_main.c(248) : warning C4146: unary minus operator applied to unsigned type, result still unsigned 1>.\source\r_main.c(264) : warning C4146: unary minus operator applied to unsigned type, result still unsigned 1>.\source\r_bsp.c(1742) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
The line numbers correspond to r830. The first two are the "octant 7" lines in R_PointToAngle and R_PointToAngle2, the third is in R_CheckBBox, the "angle2 = -clipangle" operation that happens after the check for whether it is "Totally off the left edge" or not.

Old Post Aug 26 2009 14:32 #
Gez is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Quasar
Moderator


Posts: 6560
Registered: 08-00


It is impossible to eliminate these warnings AFAIK. There is no valid portable idiom in C that will replace what these statements are trying to do to the best of my knowledge.

If you know of one, do share ;)

Old Post Aug 27 2009 16:03 #
Quasar is offline Twitter account Youtube Github || Blog || PM || Post History || Add Buddy IP || Edit || Quote
exp(x)


Posts: 2595
Registered: 04-04


What about putting a 0 in front of the minus instead of using unary minus?

Old Post Aug 27 2009 16:47 #
exp(x) is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Gez
Why don't I have a custom title by now?!


Posts: 12524
Registered: 07-07


Indeed, no warnings with lines modified as such:
code:
x > (y = 0-y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 7 angle2 = 0-clipangle;

Old Post Aug 27 2009 17:54 #
Gez is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Graf Zahl
Why don't I have a custom title by now?!


Posts: 8104
Registered: 01-03


That reminds me, is Eternity still using the Killoughized version of R_PointToAngle? Interestingly it's both far less readable and creates less efficient code than the original in Doom.exe...

That guy really had a problem with coding style. ;) What he did to these functions was just plain idiotic.

Old Post Aug 27 2009 20:14 #
Graf Zahl is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Quasar
Moderator


Posts: 6560
Registered: 08-00


What do you know? Guess I never thought of that ;)

And yes it's still the Killoughized code simply because I never thought to revert it (a number of other such single-expression functions have been unwound through the years, though). Maybe now would be a good time to look into it :)

Old Post Aug 28 2009 00:03 #
Quasar is offline Twitter account Youtube Github || Blog || PM || Post History || Add Buddy IP || Edit || Quote
exp(x)


Posts: 2595
Registered: 04-04



Quasar said:
What do you know? Guess I never thought of that ;)

Sometimes it's the simple solutions that escape us.

Old Post Aug 28 2009 00:16 #
exp(x) is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Gez
Why don't I have a custom title by now?!


Posts: 12524
Registered: 07-07


Two new warnings in r839:
code:
1>.\source\p_cmd.c(350) : warning C4013: 'P_InitLightning' undefined; assuming extern returning int 1>.\source\p_cmd.c(355) : warning C4013: 'P_ForceLightning' undefined; assuming extern returning int

Old Post Aug 31 2009 14:06 #
Gez is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
exp(x)


Posts: 2595
Registered: 04-04


Try including p_anim.h in p_cmd.c

Old Post Aug 31 2009 16:26 #
exp(x) is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Quasar
Moderator


Posts: 6560
Registered: 08-00


Guys you gotta give me more than 5 minutes after a commit to catch stuff like that ;) I appreciate the thought and effort, just don't go overboard ^_^

Old Post Aug 31 2009 18:34 #
Quasar is offline Twitter account Youtube Github || Blog || PM || Post History || Add Buddy IP || Edit || Quote
exp(x)


Posts: 2595
Registered: 04-04


I blame him.

Old Post Aug 31 2009 20:12 #
exp(x) is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Creaphis
I will deliberately take a contrary position just for the sake of writing incredibly long arguments


Posts: 4185
Registered: 10-05


Shame on you Quasar.

Old Post Aug 31 2009 20:16 #
Creaphis is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
entryway
Forum Staple


Posts: 2776
Registered: 01-04



Graf Zahl said:
That reminds me, is Eternity still using the Killoughized version of R_PointToAngle? Interestingly it's both far less readable and creates less efficient code than the original in Doom.exe...

not so much though :)
code:
unsigned int i, k, tic; tic = SDL_GetTicks(); for(i = 0; i < 1e8; i++) { k += R_PointToAngle(k, i); } I_Error("%d %d", SDL_GetTicks() - tic, k);
~1412 msec for Boom
~1374 msec for Carmack

So you can save ~0.04 sec with 100 billions of PointToAngle

btw, zdoom version (which is not used, but code is there) is 1710 msec - much slower. Used (precise) version of course is super slow - 8140 msec.

Last edited by entryway on Sep 8 2009 at 19:55

Old Post Sep 8 2009 19:36 #
entryway is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Gez
Why don't I have a custom title by now?!


Posts: 12524
Registered: 07-07


Now see what you've done.

Old Post Sep 9 2009 09:32 #
Gez is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
entryway
Forum Staple


Posts: 2776
Registered: 01-04



Gez said:
Now see what you've done.

Did not know zdoom uses that code, because gzdoom uses atan2 in both renderers.

Old Post Sep 9 2009 10:04 #
entryway is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
All times are GMT. The time now is 10:02. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Special Interest > Eternity > VC++ compile warnings

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.