• OneOfTheFew (unregistered)

    Second!

  • Tester (unregistered)

    Frist!

    And not spam!

  • Frist-BRG (unregistered)

    Not Frist1

  • XXXXX (unregistered)
    enum
    {
        Zero = 437,
        One = 437,
        Two = 437,
        Three = 437,
        Four = 437,
        Five = 437,
        Six = 437,
        Seven = 437,
        Eight = 437,
        Nine = 437,
        Ten = 437,
        Eleven = 437,
        Tweleve = 437,
        Thirteen = 437,
        Fourteen = 437,
        Fifteen = 437,
        Sixteen = 437,
        Seventeen = 437,
        Eighteen = 437,
        Nineteen = 437,
        Twenty =  = 437,
        Number_23 =  = 437,
        Sixty =  = 437,
        Number_250 =  437,
        Number_255 =  437,
        Number_500 =  437
    };
    

    Ahh, I see, problem was too much variation. FTFY

  • Adrian (unregistered)

    Shame we can't hire people for their comedy value any more.

  • Bob The builder (unregistered)

    enum{ fourth }

  • (cs)

    I'm very sorry he got burned before. It's a crying shame that he didn't get incinerated.

  • redblacktree (unregistered)

    Sounds like a moderately-intelligent comlexifier. http://jamescreasman.com/2007/10/the-smart-complexifier/

  • (cs)

    If the compiler handles the literals incorrectly, then how can he be sure that they're handled correctly when being used as the value of an enum?

  • Marcos (unregistered)

    I wonder if now the compiler will get "Tweleve" right...

  • Billy (unregistered) in reply to SCSimmons

    Oops - a big guffaw across a quiet office!

  • Inno (unregistered)

    I was under the impression that 20, 23, 60, 250, 255, 500 etc. were literals too. Must be mistaken because compilers get literal numbers wrong!

  • bedward (unregistered) in reply to Marcos
    Marcos:
    I wonder if now the compiler will get "Tweleve" right...
    That was a typo for "Tweleven".
  • xyz (unregistered) in reply to Tester
    Tester:
    Frist!

    And not spam!

    Man, get a life. Seriously.

  • Rosuav (unregistered)

    What're the odds he got "burned" when he used a literal 010 to mean ten?

  • Inno (unregistered) in reply to Rosuav
    Rosuav:
    What're the odds he got "burned" when he used a literal 010 to mean ten?

    ... or something like this did not compile: int x = 019;

  • NoAstronomer (unregistered)

    "I've seen compilers get literal numbers wrong before"

    The next time I eff up and introduce a bug I am totally using this.

  • Ross (unregistered)

    If I was in a mischievous mood, I would like to make the following change:

    Zero = -1,

    ...and watch the resulting mayhem.

  • (cs)

    Reminds me of the time a colleague got bitten by a C compiler's interpretation of some literal numbers he put in some source code.

    The year was 1991, maybe 1992. It was an embedded system (without any file system, no less) with a four-line, twenty column text-mode LCD display.

    The data to be displayed was separated into numbered pages. Page numbers were four digits, divided into section, chapter and page-in-chapter. Being software types, we naturally started at zero, which lead to a hysterical issue with the page number validation routine. You see, a large fraction of the pages numbered between 0007 and 1000 (exclusive) were declared invalid. The reason: my colleague's nicely laid out table of valid page numbers, stored in 16-bit ints, completely formatted with leading zeroes and all so they'd look like the numbers you typed on the keypad. There was no page "0xx8", so the compiler didn't crap out, but the octaliser guaranteed that not one of the numbers was interpreted the way that he thought.

    The real WTF here, however, was me. It took me three passes over the code before I noticed the leading zeroes. In his defence: as soon as I said, "They're octal," he did a facepalm and went to fix it.

  • Ski (unregistered)

    I'm new to this site, but this is the first one I've seen so far that had my mouth gaping while I read it.

  • (cs)

    I wonder if he uses a compiler he wrote.

  • Winter (unregistered)

    Got burned enough on leading zeros that every color capable IDE or editor I use, mark octal in a different color from decimal or hex.

  • Potiguar (unregistered)

    All he needed was:

    enum Numbers { forty_two = 42; }

  • Reginold (unregistered)

    Hopefully, this is a 16 bit system. Either way declaring MaxValue is a WTF of its own.

    Captcha: facilisi. Enums are not the right facilisi.

  • (cs)

    He is a witch! I say we need to burn him and his code at the stake.

  • (cs)
    The Bloviator:
    I've seen compilers get literal numbers wrong before. And I'm tired of getting burned.
    Yeah? Well I've seen compilers get literal numbers right before. So clearly you were burning yourself.

    Seriously, never let this guy touch code again. Using an enum this way is dumb. Really dumb.

  • c (unregistered)

    I have really missed a trick - in all these years it's never occurred to me that underscore plus number is a valid identifier.

  • (cs)

    I admit I appreciate his strategy: rather than "get burned" like last time, he chooses to burn everyone else. That's just being a team-player.

  • vexorian (unregistered)

    He strikes me as a guy who (like many of us) got hit by octal values one day during his beginner days. Hahaha they joy of getting compile errors or wrong values after using [08] to align some array filling code.

    Unfortunately for him, unlike what anyone with decency would do, he assumed it was yet another compiler bug that was burning him. Instead of learning about octal values. Oh well.

  • (cs) in reply to Potiguar
    Potiguar:
    All he needed was:

    enum Numbers { forty_two = 42; }

    Seriously, who hasn't made this joke?

  • geoffrey (unregistered)

    I have to say, I don't care much for these CodeSOD articles. I don't have much opportunity in these articles to put my unique technical/business acumen on display.

  • Mike M (unregistered)

    The number 23! It's everywhere!

  • soup dog (unregistered)

    I refuse to believe someone can be this stupid. Seriously. That's just freaking awful. I would take one look at this code and fire him. immediately.

  • (cs) in reply to frits
    frits:
    Potiguar:
    All he needed was:

    enum Numbers { forty_two = 42; }

    Seriously, who hasn't made this joke?
    Douglas Adams; at least, not recently.

  • (cs)

    The irony is he's getting burned by everyone on this site.

  • Meta Ethical (unregistered) in reply to vexorian
    vexorian:
    He strikes me as a guy who (like many of us) got hit by octal values one day during his beginner days. Hahaha they joy of getting compile errors or wrong values after using [08] to align some array filling code.

    Unfortunately for him, unlike what anyone with decency would do, he assumed it was yet another compiler bug that was burning him. Instead of learning about octal values. Oh well.

    I haven't used ^G but I would say that once you figure out the sticky bit in the /tmp directory, you are one step on your way to losing your liking for ACLs.

    Octal values are easy to remember because you can say them out loud. Do you remember the pronunciation? It is from the scifi novel with the city in a shield, and et the cetera. Phooey. Captcha = nibh.

  • foo (unregistered) in reply to snoofle
    snoofle:
    If the compiler handles the literals incorrectly, then how can he be sure that they're handled correctly when being used as the value of an enum?
    enum
    {
      Number_23 = Ten * Seven / Three
    };
    
    Fixed?
  • Outkast (unregistered)

    enum {

    One = 1, Two = 2, Three = 3, Uh = 4, My_baby_dont_mess_around = 5, Because_she_loves_me_so= 6 And_this_I_know_for_shooo= 7, Heyyyyy_yaaaaa = 8 };

  • Today's WTF (unregistered)

    So does he have an enum for all the possible calculations from his enum?

    enum { ZeroPlusOne, OnePlusOne, TwoPlusOne, ... }

    yknow cause the compiler could burn you that way too...sneaky compilers!

  • Buddy (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    ... The real WTF here, however, was me. It took me three passes over the code before I noticed the leading zeroes. In his defence: as soon as I said, "They're octal," he did a facepalm and went to fix it.

    Yeah, that's what probably burned the Bloviator. One of those gotchas in C, like opening files in binary vs. text, missing a break in a switch statement, nested if-then-else not behaving as expected, operator precedence, = vs ==, printf format string mismatch, the unholy strtok (useless, should be banished), the evil gets (now banished), etc.! No doubt, C is a brutal language, just one step above assembler.

  • iToad (unregistered)

    This is a clear case where a Software Engineer IV needs to be busted back to Software Engineer I, until he learns how to use enums correctly. Hint: Depending on their numeric values isn't very smart.

    People who do this crap wouldn't recognize a #define if it bit them on the ass.

  • Your Name (unregistered) in reply to c
    c:
    I have really missed a trick - in all these years it's never occurred to me that underscore plus number is a valid identifier.

    Technically, in C and C++, any identifier with a leading underscore is reserved. In practice they usually work, until they don't.

    You run into that a lot in C/C++, where something is outside the standard but in common usage and then people start whining when a new version of a compiler starts rejecting their code.

  • Buddy (unregistered) in reply to frits
    frits:
    Potiguar:
    All he needed was:

    enum Numbers { forty_two = 42; }

    Seriously, who hasn't made this joke?

    Correction:

    enum Numbers
    {
       forty_two = six times nine;
    }
  • (cs)

    Burned by octal, never forgotten. This guy carries long grudges

  • The Mice (unregistered) in reply to Potiguar
    Potiguar:
    All he needed was:

    enum Numbers { forty_two = 42; }

    enum Numbers { forty_two = how_many_roads_must_a_man_walk_down }

  • Todd Lewis (unregistered) in reply to bedward
    bedward:
    Marcos:
    I wonder if now the compiler will get "Tweleve" right...
    That was a typo for "Tweleven".
    "eleven plus two" is an anagram of "twelve plus one", so you can see why a compiler would get confused...
  • ricecake (unregistered) in reply to Your Name
    Your Name:
    Technically, in C and C++, any identifier with a leading underscore is reserved.
    Almost; they are only reserved if the name is in the global namespace. Identifiers with a leading underscore followed by an uppercase letter, however, are reserved exclusively for the implementation. Therefore, you can use leading underscores followed by numbers or lowercase letters for local identifiers.
  • King Erroneous (unregistered) in reply to Outkast

    Another keyboard, you owe me one.

  • Timothy (unregistered)

    Wierdly enough, a major C++ compiler I have worked with has/had an obscure bug that would in very rare circumstances duplicate a character. I think it was an off by one bug in the lexical analyzer. So my source might contain the line:

    int var2 = var1;

    and the compiler would be treating it as

    int var2 = vaar1;

    I would "solve" the compiler error by putting a long comment on the line before, to shift the error into the comment.

    It was a worry that the bug might occur someplace that didn't break the source code. I can easily imagine "x = 1;" getting turned into "x = 11;".

    It was a pretty rare bug, though, and only seemed to occur in source files that were so long they were inherently WTFs.

  • (cs) in reply to Anketam
    Anketam:
    He is a witch! I say we need to burn him and his code at the stake.
    Inb4 "He's turned me into a newt!"

Leave a comment on “Tired of Getting Burned”

Log In or post as a guest

Replying to comment #:

« Return to Article