Thread: Wired all But Not errors

  1. #1
    Registered User
    Join Date
    Jun 2007

    Wired all But Not errors

    Her is My Code on
    Everything is Fine If I just remove line 68 and 69
    Else Its Showing Wired texts But not errors.
    see here is teh Output
    describing pt initialized               x = 4   y = 10
    describing px returned from pre inc     x = 5   y = 11
    describing pt after Pre Incrementing    x = 5   y = 11
    describing py returned from post inc    x = 5   y = 11
    describing pt after Post Increment      x = 6   y = 12
    describing pt1 after Init with new      x = 80  y = 100
    describing pt1 after Pre Incrementing   x = 81  y = 101
    describing After py += px               x = 10  y = 22
    describing After py+= pt1               x = 91  y = 123
    describing py after py += 2             x = 93  y = 125
    describing pt1 After pt1 += 2   x = 0   y = 0
    *** glibc detected *** /root/Desktop/op_overload: double free or corruption (top): 0x0804a018 ***
    ======= Backtrace: =========
    ======= Memory map: ========
    08048000-08049000 r-xp 00000000 08:0a 145784     /root/Desktop/op_overload
    08049000-0804a000 rw-p 00001000 08:0a 145784     /root/Desktop/op_overload
    0804a000-0806b000 rw-p 0804a000 00:00 0          [heap]
    b7c00000-b7c21000 rw-p b7c00000 00:00 0 
    b7c21000-b7d00000 ---p b7c21000 00:00 0 
    b7d04000-b7d05000 rw-p b7d04000 00:00 0 
    b7d05000-b7e40000 r-xp 00000000 08:0a 291032     /lib/tls/i686/cmov/
    b7e40000-b7e41000 r--p 0013b000 08:0a 291032     /lib/tls/i686/cmov/
    b7e41000-b7e43000 rw-p 0013c000 08:0a 291032     /lib/tls/i686/cmov/
    b7e43000-b7e46000 rw-p b7e43000 00:00 0 
    b7e46000-b7e51000 r-xp 00000000 08:0a 290894     /lib/
    b7e51000-b7e52000 rw-p 0000a000 08:0a 290894     /lib/
    b7e52000-b7e53000 rw-p b7e52000 00:00 0 
    b7e53000-b7e78000 r-xp 00000000 08:0a 291037     /lib/tls/i686/cmov/
    b7e78000-b7e7a000 rw-p 00024000 08:0a 291037     /lib/tls/i686/cmov/
    b7e7a000-b7f59000 r-xp 00000000 08:0a 18744      /usr/lib/
    b7f59000-b7f5c000 r--p 000de000 08:0a 18744      /usr/lib/
    b7f5c000-b7f5e000 rw-p 000e1000 08:0a 18744      /usr/lib/
    b7f5e000-b7f64000 rw-p b7f5e000 00:00 0 
    b7f74000-b7f77000 rw-p b7f74000 00:00 0 
    b7f77000-b7f90000 r-xp 00000000 08:0a 290895     /lib/
    b7f90000-b7f92000 rw-p 00019000 08:0a 290895     /lib/
    bff0b000-bff20000 rw-p bff0b000 00:00 0          [stack]
    ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
    Program has been terminated receiving signal 6 (Aborted)
    But If I use
    *pt1 +=2;
    Instead of Object pt It works Fine.
    I thought It will Fire Error With Usinfg Without Pointer here
    But Why its Pulling glibC ??
    Last edited by noobcpp; 07-01-2007 at 11:07 AM.

  2. #2
    Registered User
    Join Date
    Aug 2005
    	pt1 +=2;//For this Line its showing Wired
    This calls operator + for a pointer
    after that pt1 points to something that is not a Point.
    Deleting it crashes.

  3. #3
    Registered User
    Join Date
    Jan 2005
    >> I thought It will Fire Error With Usinfg Without Pointer here But Why its Pulling glibC ??

    You are allowed to add a number to a pointer. It is called pointer arithmetic. However, it does bad things in this example. So the compiler allows it because it trusts you that you want to add a number to the pointer, but then when you try to run the program you get an error because it does bad things.

    There are many situations where the compiler trusts you that you know what you are doing. If you do something wrong, it will compile the program and the program will run but do bad things. Sometimes that means it will crash, sometimes it means it will give you incorrect results, sometimes that means it will work for a long time and then fail once when you need it. This is what undefined behavior means.

  4. #4
    Registered User
    Join Date
    Jun 2007
    Ah! OK.

  5. #5
    Registered User
    Join Date
    Jun 2007
    I think I've done Pointer Arithmatic before Without knowing what it is in my other Thread.
    in this Way *ptr++;
    But didnt Understand it Properly.
    I've Practical C++ By McGragor
    It has a Programm on Pointer Arithmetic But I cant Run it on g++ Linux
    Do anyone have any simple example Programm on it that I can Run on my Compiler ??
    That Can be compiled on VC++ But I dont have Windows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 04:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 11:50 AM
  3. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 03:57 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM
Website Security Test