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. General Programming
  3. C / C++ / MFC
  4. VC++ 6.0 string bug ? (take a look plz)

VC++ 6.0 string bug ? (take a look plz)

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingperformancequestion
30 Posts 6 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.
  • N Neville Franks

    Your code works fine for me as well in both Debug and Release builds on WinXP Pro. That is I "anystringabcde" Have you tried rebooting Windows? If all else fails... Neville Franks, Author of ED for Windows. www.getsoft.com

    L Offline
    L Offline
    Lockhart
    wrote on last edited by
    #21

    This is a very strange problem... rebooted, underclocked the processor, I have no idea... it still gives me different results: In Debug "anystringabcde" In Release "anystringBUG!" When Optimizations is MazimizeSpeed(default setting) Thanks for your time :(

    N 1 Reply Last reply
    0
    • L Lockhart

      This is a very strange problem... rebooted, underclocked the processor, I have no idea... it still gives me different results: In Debug "anystringabcde" In Release "anystringBUG!" When Optimizations is MazimizeSpeed(default setting) Thanks for your time :(

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #22

      Have you tried stepping through it in the debugger and seeing where 'result' screws up. You can still debug release builds by including debug info. I think there is an article by Mr. Newcomer here on CP about this. Neville Franks, Author of ED for Windows. www.getsoft.com

      L 1 Reply Last reply
      0
      • N Neville Franks

        Have you tried stepping through it in the debugger and seeing where 'result' screws up. You can still debug release builds by including debug info. I think there is an article by Mr. Newcomer here on CP about this. Neville Franks, Author of ED for Windows. www.getsoft.com

        L Offline
        L Offline
        Lockhart
        wrote on last edited by
        #23

        I have found the article, thanks! Very interesting http://www.codeproject.com/debug/survivereleasever.asp) But life is hard: I have turned on debugging information for Release and the compiler gives me this error asa I press F5: "Command line error D2016 : '/ZI' and '/O2' command-line options are incompatible" /O2 is the parameter for the Optimization->MazimixeSpeed, and if I turn it OFF the bug doesn't appear, so debugging is useless in this case! Nice... Maybe I have to reinstall, I don't know

        N 1 Reply Last reply
        0
        • L Lockhart

          I have found the article, thanks! Very interesting http://www.codeproject.com/debug/survivereleasever.asp) But life is hard: I have turned on debugging information for Release and the compiler gives me this error asa I press F5: "Command line error D2016 : '/ZI' and '/O2' command-line options are incompatible" /O2 is the parameter for the Optimization->MazimixeSpeed, and if I turn it OFF the bug doesn't appear, so debugging is useless in this case! Nice... Maybe I have to reinstall, I don't know

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #24

          You can still debug but you'll need to be able to work through the Assembler code. If you started with Assembler like I did this isn't too difficult. Another option is to use: OutputDebugString() Neville Franks, Author of ED for Windows. www.getsoft.com

          T L 2 Replies Last reply
          0
          • N Neville Franks

            You can still debug but you'll need to be able to work through the Assembler code. If you started with Assembler like I did this isn't too difficult. Another option is to use: OutputDebugString() Neville Franks, Author of ED for Windows. www.getsoft.com

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #25

            Debugging assembler is a dying skill. :( Thank god I learned it years and years ago. I use that skill all the time. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

            N 1 Reply Last reply
            0
            • T Tim Smith

              Debugging assembler is a dying skill. :( Thank god I learned it years and years ago. I use that skill all the time. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

              N Offline
              N Offline
              Neville Franks
              wrote on last edited by
              #26

              Tim Smith wrote: Debugging assembler is a dying skill. Thank god I learned it years and years ago. I use that skill all the time. Yes I couldn't agree more. My guess is that these days most programmers wouldn't have a clue about Assembler. I started programming in Signetics 2650 Assembler with 8K RAM, and spent a number of years writing Z80/8080 Assembler. In fact the very first versions of my programmers editor (ED) were writtem in 2650 Assembler. It sure has come an awefully long way to what you see today. Thank god for C/C++, but having said that I still dip in to the Assembler listings from time to time while debugging. I would also take a punt and say many developers today don't use a Debugger enough. Neville Franks, Author of ED for Windows. www.getsoft.com

              T 1 Reply Last reply
              0
              • N Neville Franks

                Tim Smith wrote: Debugging assembler is a dying skill. Thank god I learned it years and years ago. I use that skill all the time. Yes I couldn't agree more. My guess is that these days most programmers wouldn't have a clue about Assembler. I started programming in Signetics 2650 Assembler with 8K RAM, and spent a number of years writing Z80/8080 Assembler. In fact the very first versions of my programmers editor (ED) were writtem in 2650 Assembler. It sure has come an awefully long way to what you see today. Thank god for C/C++, but having said that I still dip in to the Assembler listings from time to time while debugging. I would also take a punt and say many developers today don't use a Debugger enough. Neville Franks, Author of ED for Windows. www.getsoft.com

                T Offline
                T Offline
                Tim Smith
                wrote on last edited by
                #27

                I learned on the 8080/85, Z80, and 6809 processors. Ah, the good old days. My first C compiler was ECO-C. This was back in the days when a C compiler generated ASM code which you then sent into the assembler. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

                1 Reply Last reply
                0
                • N Neville Franks

                  You can still debug but you'll need to be able to work through the Assembler code. If you started with Assembler like I did this isn't too difficult. Another option is to use: OutputDebugString() Neville Franks, Author of ED for Windows. www.getsoft.com

                  L Offline
                  L Offline
                  Lockhart
                  wrote on last edited by
                  #28

                  I have a little experience with ASM, learnt at Uni and played at home, I'll give a look at it but maybe another problem has come out. I have installed WinXP few weeks ago and I notice that no symbols are found during debugging. Maybe I have to download this 150MB package from MS site (windowsxp.x86.fre.rtm.symbols.exe) Another strange thing appened: if I put AfxMessageBox(s1) before strcpy(), the bug vanishes: void Buggy( char* result ) { char s1[6]; char s2[5]; strcpy(s1,"abcde"); strcpy(s2,"BUG!"); AfxMessageBox(s1); // DOESNT WORK strcpy(result,"anystring"); strcat(result,s1); } It displays "abcde" and 'result' is filled with "anystringabcde". If I comment out AfxMessageBox(s1) 'result' is filled with "anystringBUG!". I have made several programs, some little, others bigger, but I had never seen these strange beahviours, especially because on other PCs compiles fine. I must admit that I'm not expert in debugging, I prefer to proceed slowly, and run the program just after having added/removed some lines of code. Lately I have installed and removed MySQL, MSDE, various ServicePacks, maybe something has been wrong and I didn't notice.

                  N 1 Reply Last reply
                  0
                  • L Lockhart

                    I have a little experience with ASM, learnt at Uni and played at home, I'll give a look at it but maybe another problem has come out. I have installed WinXP few weeks ago and I notice that no symbols are found during debugging. Maybe I have to download this 150MB package from MS site (windowsxp.x86.fre.rtm.symbols.exe) Another strange thing appened: if I put AfxMessageBox(s1) before strcpy(), the bug vanishes: void Buggy( char* result ) { char s1[6]; char s2[5]; strcpy(s1,"abcde"); strcpy(s2,"BUG!"); AfxMessageBox(s1); // DOESNT WORK strcpy(result,"anystring"); strcat(result,s1); } It displays "abcde" and 'result' is filled with "anystringabcde". If I comment out AfxMessageBox(s1) 'result' is filled with "anystringBUG!". I have made several programs, some little, others bigger, but I had never seen these strange beahviours, especially because on other PCs compiles fine. I must admit that I'm not expert in debugging, I prefer to proceed slowly, and run the program just after having added/removed some lines of code. Lately I have installed and removed MySQL, MSDE, various ServicePacks, maybe something has been wrong and I didn't notice.

                    N Offline
                    N Offline
                    Neville Franks
                    wrote on last edited by
                    #29

                    Frankesk wrote: Lately I have installed and removed MySQL, MSDE, various ServicePacks, maybe something has been wrong and I didn't notice. Maybe one of the MFC DLL's has gone back to an old version. About now I'd suggest re-installing VC++. Neville Franks, Author of ED for Windows. www.getsoft.com

                    L 1 Reply Last reply
                    0
                    • N Neville Franks

                      Frankesk wrote: Lately I have installed and removed MySQL, MSDE, various ServicePacks, maybe something has been wrong and I didn't notice. Maybe one of the MFC DLL's has gone back to an old version. About now I'd suggest re-installing VC++. Neville Franks, Author of ED for Windows. www.getsoft.com

                      L Offline
                      L Offline
                      Lockhart
                      wrote on last edited by
                      #30

                      I have reinstalled, now all works... Thanks for your time

                      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