0

Does codeblock have a bug?

I ran a pointer example both g++ compiler of ubuntu and codeblock. The results are Ox7fff1b6c9348 and 5 respectively. How can solve this problem? Thank you.

27th Mar 2019, 8:49 PM
berna uyanık
berna uyanık - avatar
4 ответов
+ 3
Please show your code. Even without seeing the code, I doubt that Code Blocks has a bug that is so severe that pointers are arbitrarily dereferenced. So there's probably something wrong with your code https://www.sololearn.com/discuss/1316935/?ref=app
28th Mar 2019, 6:15 AM
Anna
Anna - avatar
+ 3
Never use x = ++x or something like that. The syntax is wrong. In general, never change the value of a variable more than once in the same statement, so avoid expressions like x -= x--, x = x++ + ++x etc. ++x increases x by one. What x = ++x does is undefined. I don't know if that's the only issue with your code, but undefined behavior could explain why you get different outputs in different IDEs.
28th Mar 2019, 5:50 PM
Anna
Anna - avatar
0
#include<iostream> using namespace std; int main(){ int *p = new int; *p=10; int x1,x2,y1,y2,sum; x1=5; x2=5; x1=x1++; y1=x1; x2=++x2; y2=x2; cout << &y1 <<","<<y2 <<";"<<p<<endl; cout<<sizeof(char)<<endl; cout<<sizeof(double)<<endl; }
28th Mar 2019, 4:24 PM
berna uyanık
berna uyanık - avatar
0
But first I ran without pointers. I noticed if the program changes, run function of codeblock do not build it again. After I pressed build and run button, it gave correct results. Thank you.
28th Mar 2019, 4:27 PM
berna uyanık
berna uyanık - avatar