Weird program behaviour on one laptop

Ido Berkovits 20 Reputation points
2023-04-11T10:59:52.1233333+00:00

Hello, I am a CS student, and I have an assignment in OOP(*disclaimer, I already submitted the project, so I'm not looking for guidance).

The teacher gave us an image with the expected result, and the Main.cpp file, and we had to "reverse engineer" the functions he provided, and write them ourselves to match the output he has given us.

The project itself includes Main.cpp, Polynomial.cpp, Rational.cpp, Polynomial.h and Rational.h files.

When I run the project on my laptop(Windows 11 if that matters, and VS 2022 community edition), the program "crashes" just before the end of the file, but when I run the same project, on a different computer(I've tried several computers, some were running Windows 10, and some Windows 11, and VS 2022 or VS 2019 community editions), and everything runs just fine.

I even tried reinstalling VS completely, and restore all it's settings to default, and I also tried making an entire new project on a different directory, and nothing worked. I tried disabling the Anti-virus, tried running the program via CMD(and PowerShell), and I checked the project settings to see if anything is out of the ordinary, but nothing "popped up".

When I run the program with the debugger, it runs just fine, no exceptions or errors whatsoever.

I can't find any solutions online regarding this issue, so I was hoping someone here might have a clue on why it's happening.

I provided the image with the result I'm getting when running the debugger, and one when I run it without the debugger.

Thank you in advance.

Picture1

Picture2

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
{count} votes

Answer accepted by question author
  1. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2023-04-13T07:45:47.3866667+00:00

    Hi,@Ido Berkovits

    I reproduce your problem successfully. Apparently this is a bug with Visual Studio and it happens randomly. The first time I ran the program without debugging: User's image

    And second time I removed a space in snippet and rebuild the program again.

    Before: cout << "test10 :maxDegree = " << Polynomial::getMaxDegree() << endl;

    After: cout << "test10 :maxDegree = " << Polynomial::getMaxDegree()<< endl;

    enter image description here

    You could report the problem to Developer Commnunityand post link here.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.