Click here to Skip to main content
15,901,426 members

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.

 
AnswerRe: Interesting technique used in some Legacy code! Pin
Super Lloyd18-Jun-14 20:35
Super Lloyd18-Jun-14 20:35 
GeneralRe: Interesting technique used in some Legacy code! Pin
Stefan_Lang20-Jun-14 4:34
Stefan_Lang20-Jun-14 4:34 
GeneralRe: Interesting technique used in some Legacy code! Pin
Super Lloyd20-Jun-14 5:26
Super Lloyd20-Jun-14 5:26 
GeneralCodeProject Daily News - The only newsletter I would, deliberately, subscribe to PinPopular
Adam Tibi10-Jun-14 23:25
professionalAdam Tibi10-Jun-14 23:25 
GeneralRe: CodeProject Daily News - The only newsletter I would, deliberately, subscribe to Pin
JMK-NI10-Jun-14 23:42
professionalJMK-NI10-Jun-14 23:42 
GeneralRe: CodeProject Daily News - The only newsletter I would, deliberately, subscribe to Pin
PIEBALDconsult12-Jun-14 3:08
mvePIEBALDconsult12-Jun-14 3:08 
GeneralRe: CodeProject Daily News - The only newsletter I would, deliberately, subscribe to Pin
OriginalGriff16-Jun-14 5:28
mveOriginalGriff16-Jun-14 5:28 
GeneralEnhanced Password Security Pin
Bernhard Hiller10-Jun-14 21:08
Bernhard Hiller10-Jun-14 21:08 
JokeRe: Enhanced Password Security Pin
Kornfeld Eliyahu Peter10-Jun-14 22:17
professionalKornfeld Eliyahu Peter10-Jun-14 22:17 
GeneralRe: Enhanced Password Security Pin
Eddy Vluggen11-Jun-14 0:29
professionalEddy Vluggen11-Jun-14 0:29 
GeneralRe: Enhanced Password Security Pin
Trajan McGill11-Jun-14 3:07
Trajan McGill11-Jun-14 3:07 
GeneralRe: Enhanced Password Security Pin
PIEBALDconsult11-Jun-14 12:02
mvePIEBALDconsult11-Jun-14 12:02 
GeneralRe: Enhanced Password Security Pin
PIEBALDconsult11-Jun-14 12:10
mvePIEBALDconsult11-Jun-14 12:10 
GeneralDateTime.Now vs. GetSystemTime Pin
Bernhard Hiller30-May-14 0:17
Bernhard Hiller30-May-14 0:17 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Pete O'Hanlon30-May-14 1:05
mvePete O'Hanlon30-May-14 1:05 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Bernhard Hiller2-Jun-14 0:30
Bernhard Hiller2-Jun-14 0:30 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Pete O'Hanlon2-Jun-14 0:32
mvePete O'Hanlon2-Jun-14 0:32 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Jörgen Andersson2-Jun-14 21:11
professionalJörgen Andersson2-Jun-14 21:11 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Bernhard Hiller2-Jun-14 21:35
Bernhard Hiller2-Jun-14 21:35 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Jörgen Andersson2-Jun-14 21:56
professionalJörgen Andersson2-Jun-14 21:56 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
BobJanova2-Jun-14 0:51
BobJanova2-Jun-14 0:51 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Rob Philpott10-Jun-14 5:20
Rob Philpott10-Jun-14 5:20 
GeneralRe: DateTime.Now vs. GetSystemTime Pin
Eddy Vluggen6-Jun-14 5:11
professionalEddy Vluggen6-Jun-14 5:11 
GeneralSuccessfully writing to a string literal Pin
Indivara18-May-14 23:44
professionalIndivara18-May-14 23:44 
Had to debug a crash today where the 32 bit build of an application was crashing, but the 64 bit build wasn't. There was a method that takes a string (char *) buffer as an in / out argument as follows.
void SomeClass::someMethod(char * arg1, /* some other args */)
{
    // do something
    
    arg1[i] = '\0'; // i is a location within the buffer's size
    return;
}

The caller was supposed to call it with a variable, but one caller was passing a string literal, so naturally it caused an access violation.
obj.someMethod("string_literal");

However the 64 bit build was working fine. After some fiddling around, I discovered that it was due to the project's optimization settings. The assignement apparently has no effect, so the compiler was removing it in the 64 bit build. Disabling optimization caused the 64 bit build to crash too.

Of course I had to come up with all kinds of crazy reasons first, thinking it was something to do with how 64 bit applications pass arguments, etc.

No more in/outs. const char * is much safer, and will keep you sane (until you cast away the const, of course).
GeneralRe: Successfully writing to a string literal Pin
Freak3019-May-14 1:45
Freak3019-May-14 1:45 

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.