Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. Here's an interesting little 'gotcha' I encountered a little while ago

Here's an interesting little 'gotcha' I encountered a little while ago

Scheduled Pinned Locked Moved Clever Code
phpcomdebugginghelpquestion
4 Posts 3 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    damnedyankee
    wrote on last edited by
    #1

    http://www.yankeeboysoftware.com/wordpress/?p=10 I think I spent about a half an hour working out what the issue was, and onlyfound it when I decided to trace into the hashing function. Of course it was all my own fault, but I still find it interesting and amusing.

    L 1 Reply Last reply
    0
    • D damnedyankee

      http://www.yankeeboysoftware.com/wordpress/?p=10 I think I spent about a half an hour working out what the issue was, and onlyfound it when I decided to trace into the hashing function. Of course it was all my own fault, but I still find it interesting and amusing.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      this aint reddit, you have to tell us here!

      xacc.ide - now with IronScheme support
      IronScheme - 1.0 alpha 2 out now

      D 1 Reply Last reply
      0
      • L leppie

        this aint reddit, you have to tell us here!

        xacc.ide - now with IronScheme support
        IronScheme - 1.0 alpha 2 out now

        D Offline
        D Offline
        damnedyankee
        wrote on last edited by
        #3

        Here is a snippet of code which illustrates the bug. set set; stringstream ss; string s; ss << 't' << 'e' << 's' << 't'; s = ss.str(); cout << "inserting [" << s << ']' << endl; set.insert(s); ss << ends; // now add the null terminator s = ss.str(); cout << "looking for [" << s << ']' << endl; if(set.end() == set.find(s)) cout << "NOT FOUND" << endl; else cout << "FOUND" << endl; This was hard to find with the debugger which of course displays a ull terminated string the same way it displays a non-terminated string

        D 1 Reply Last reply
        0
        • D damnedyankee

          Here is a snippet of code which illustrates the bug. set set; stringstream ss; string s; ss << 't' << 'e' << 's' << 't'; s = ss.str(); cout << "inserting [" << s << ']' << endl; set.insert(s); ss << ends; // now add the null terminator s = ss.str(); cout << "looking for [" << s << ']' << endl; if(set.end() == set.find(s)) cout << "NOT FOUND" << endl; else cout << "FOUND" << endl; This was hard to find with the debugger which of course displays a ull terminated string the same way it displays a non-terminated string

          D Offline
          D Offline
          Derek Bartram
          wrote on last edited by
          #4

          I've had simmilar issues with C# and VS2008.... Especially when adding new line characters, never easy to fix.... A simple debug tip is to do String debugString = theString.Replace("\r\n", "@@@"); and then breakpoint the line after.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups