Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
D--M22667yDon't hate the tool just because you can't be bothered to turn off optimisation in debug
-
Teakay87yIn C you can add volatile to variables, maybe it works in C++ too, optimizers won't optimize volatile variables
-
lol why does the compiler remove variables it needs? wtf is going on
that doesnt really count as "optimisation", but rather as "breaking" -
@simulate the errors are in the watch. People need to learn more about the platform and compiler they're working on.
-
Teakay87y@IllSlapU normally you attach it in front of the variable like „volatile double variableName“
In my C class we had a similar problem like OP in our C Code. the teacher told us to use volatile so the optimizer would ignore this specific variable. -
740027567yvolatile means the value can change without a explicit write from the program. Therefore a volatile variable is always read from its memory location and not assumed to be unchanged between two read operations. Generally this keyword is only needed in low-level applications (peripheral access, dealing with interrupts).
-
IRonnyc2667y@D--M we turned of optimization and the program ran through. This is not about being to lazy to turn of optimization but the fact that the it randomly removed values.
-
fuckwit12167y@IRonnyc You are running optimised so instead of copying the value to p it will just look into the array. It is not removing any values just avoiding unnecessary allocations
-
IRonnyc2667y@fuckwit sounds right.
I shared the picture mostly because the debugger said it had been removed by optimization.
@irene I think the values were actual NaN values because when we fixed the calculation for the values it suddenly worked.
(in a vector magnitude calculation somebody wrote something like sqrt(x^2 * y^2 + z^2)) -
@demortes @AndSoWeCode @irene
ah, I get it. yeah ok you cant expect full watch support for an optimised application. I thought those were compiler errors. -
IRonnyc2667y@irene that makes sense.
Still the watches should have shown the value of p (at least it does in other languages and other IDEs).
@D--M you're at least partially right. I'm no expert in assembly, I'm no expert when it comes to what the compiler optimizes and I'm no expert in C/C++ using visual studio. I don't think I ever said I were an expert.
Currently I'm mostly programming using C# and Java.
I know basic stuff about optimization; the compiler will optimize the code to improve performance.
Higher optimization often means more in lining, unwrapping of loops etc. while sometimes even removing unnecessary stuff, making it harder and harder to debug your code. That's why one should use /Od for debugging....
If you're really going for performance you can use memory alignment to reduce the size of classes in memory making the whole thing more cache friendly.
(Yes I did look up the flag, I don't have a problem admitting that.)
No matter how high the optimization is, it shouldn't change the output of what you receive...
I'm not quite sure if the optimization did change to output that was written to the file. We found what you can see in the image while trying to find the source of some NaN values that were written to that file, making it unusable... (three.js json file if you care)
Related Rants
"The variable has been removed during optimization and is not available".
Sometimes I really hate Visual Studio...
rant
visual studio
thanks for nothing
fuck you