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. The Weird and The Wonderful
  4. Something is not as I expected

Something is not as I expected

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpvisual-studiohelp
6 Posts 4 Posters 0 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.
  • M Offline
    M Offline
    Mohibur Rashid
    wrote on last edited by
    #1

    look at the code below:

    int main(){
    char *c=new char[10];
    delete [10,05]c;
    return 0;
    }

    compile fine in visual studio 2008 and error in gcc.

    I wish I could believe there is an after life.

    A R 2 Replies Last reply
    0
    • M Mohibur Rashid

      look at the code below:

      int main(){
      char *c=new char[10];
      delete [10,05]c;
      return 0;
      }

      compile fine in visual studio 2008 and error in gcc.

      I wish I could believe there is an after life.

      A Offline
      A Offline
      AlphaDeltaTheta
      wrote on last edited by
      #2

      What happens during execution?

      M 1 Reply Last reply
      0
      • A AlphaDeltaTheta

        What happens during execution?

        M Offline
        M Offline
        Mohibur Rashid
        wrote on last edited by
        #3

        With Visual studio, work fine, with g++ compilation error

        I wish I could believe there is an after life.

        A 1 Reply Last reply
        0
        • M Mohibur Rashid

          With Visual studio, work fine, with g++ compilation error

          I wish I could believe there is an after life.

          A Offline
          A Offline
          AlphaDeltaTheta
          wrote on last edited by
          #4

          It runs successfully without errors then...:confused: Wow! :omg:

          1 Reply Last reply
          0
          • M Mohibur Rashid

            look at the code below:

            int main(){
            char *c=new char[10];
            delete [10,05]c;
            return 0;
            }

            compile fine in visual studio 2008 and error in gcc.

            I wish I could believe there is an after life.

            R Offline
            R Offline
            Rob Grainger
            wrote on last edited by
            #5

            This is a (rather pointless) MS extension to C++: Pointless extension[^] In your case, the comma operator will just throw away so the 10, so it becomes:

            delete [05] c;

            (Where 05 is an octal number) And in fact will be ignored, rendering the result exactly the same as:

            delete [] c;

            "Ours not to reason why".

            "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

            D 1 Reply Last reply
            0
            • R Rob Grainger

              This is a (rather pointless) MS extension to C++: Pointless extension[^] In your case, the comma operator will just throw away so the 10, so it becomes:

              delete [05] c;

              (Where 05 is an octal number) And in fact will be ignored, rendering the result exactly the same as:

              delete [] c;

              "Ours not to reason why".

              "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

              D Offline
              D Offline
              DarkChuky CR
              wrote on last edited by
              #6

              Sh** I remember that ',' I school days, first curse in all year using Visual C++... beautiful monitors of 14" at 1024*768... We were calculating taxes for students based on Age and grade... There were some students that were paying always 0.00 ... we debug (we were students, still stupids at debuging)... noting show wrong... After like 5 hours... I went to play Ping Ping.. I returned, found my 2 teammates debugging.. then I notices and ask: Guys is that payment * 0.05 or payment * 0,05... I learned that day that VC++ when 0,05 does Payment * 0 * 05.. then everything become 0!!!!

              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