Click here to Skip to main content
12,999,760 members (43,409 online)

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Let's "switch" to Something Else Pin
Gary Wheeler4-Apr-13 0:47
memberGary Wheeler4-Apr-13 0:47 
GeneralRe: Let's "switch" to Something Else Pin
jibalt5-Apr-13 19:21
memberjibalt5-Apr-13 19:21 
GeneralRe: Let's "switch" to Something Else Pin
Gary Wheeler8-Apr-13 0:11
memberGary Wheeler8-Apr-13 0:11 
GeneralRe: Let's "switch" to Something Else Pin
CodeBubba9-Apr-13 1:52
memberCodeBubba9-Apr-13 1:52 
GeneralRe: Let's "switch" to Something Else Pin
RafagaX9-Apr-13 4:56
memberRafagaX9-Apr-13 4:56 
GeneralRe: Let's "switch" to Something Else Pin
Dan Sutton9-Apr-13 6:34
memberDan Sutton9-Apr-13 6:34 
GeneralRe: Let's "switch" to Something Else Pin
jschell9-Apr-13 9:08
memberjschell9-Apr-13 9:08 
GeneralRe: Let's "switch" to Something Else Pin
Martin081510-Apr-13 1:41
memberMartin081510-Apr-13 1:41 
In my eyes it is ugly, but one of the easies way to compare strings (up to 8 bytes) in a most efficient way.

If it's needed and documented ... ok.

I recently saw a very strange way to copy an object in C++:

  1. the class defines all its data member attributes within 64 Byte

  2. the data member attributes are ordered to use alignment efficently

  3. copying the class is done this way (or similar)
    C64bitClass  src, dst;
     
    // cast the pointer to the source/destination object to __int64 pointers
    __int64 *pnSrc = static_cast<__int64*>(&src);
    __int64 *pnDst = static_cast<__int64*>(&dst);
     
    // copy the first 64bit of the object - the data of the object
    *pnDst = *pnSrc;



This really ugly, isn't it!
GeneralThings that make you go WTF... Pin
Gary Wheeler1-Apr-13 1:32
memberGary Wheeler1-Apr-13 1:32 
GeneralRe: Things that make you go WTF... Pin
Matt T Heffron1-Apr-13 8:53
memberMatt T Heffron1-Apr-13 8:53 
GeneralRe: Things that make you go WTF... Pin
Gary Wheeler1-Apr-13 8:59
memberGary Wheeler1-Apr-13 8:59 
GeneralRe: Things that make you go WTF... Pin
Brisingr Aerowing1-Apr-13 9:48
professionalBrisingr Aerowing1-Apr-13 9:48 
GeneralRe: Things that make you go WTF... Pin
Pete O'Hanlon2-Apr-13 7:17
protectorPete O'Hanlon2-Apr-13 7:17 
GeneralRe: Things that make you go WTF... Pin
Gary Wheeler2-Apr-13 7:25
memberGary Wheeler2-Apr-13 7:25 
GeneralRe: Things that make you go WTF... Pin
patbob2-Apr-13 5:49
memberpatbob2-Apr-13 5:49 
GeneralRe: Things that make you go WTF... Pin
Gary Wheeler2-Apr-13 6:38
memberGary Wheeler2-Apr-13 6:38 
GeneralRe: Things that make you go WTF... Pin
patbob2-Apr-13 8:03
memberpatbob2-Apr-13 8:03 
JokeRe: Things that make you go WTF... Pin
RafagaX2-Apr-13 6:50
memberRafagaX2-Apr-13 6:50 
GeneralRe: Things that make you go WTF... Pin
AspDotNetDev2-Apr-13 8:11
protectorAspDotNetDev2-Apr-13 8:11 
GeneralRe: Things that make you go WTF... Pin
Gary Wheeler2-Apr-13 8:24
memberGary Wheeler2-Apr-13 8:24 
GeneralRe: Things that make you go WTF... Pin
BobJanova3-Apr-13 23:29
memberBobJanova3-Apr-13 23:29 
GeneralRe: Things that make you go WTF... Pin
Gary Wheeler4-Apr-13 0:44
memberGary Wheeler4-Apr-13 0:44 
GeneralThat was weird... Pin
Brisingr Aerowing28-Mar-13 7:57
memberBrisingr Aerowing28-Mar-13 7:57 
GeneralRe: That was weird... Pin
Julien Villers8-Apr-13 5:10
memberJulien Villers8-Apr-13 5:10 
GeneralRe: That was weird... Pin
Brisingr Aerowing8-Apr-13 14:06
professionalBrisingr Aerowing8-Apr-13 14:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 24 Jun 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid