Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parameter mutations within functions are not shown #23

Open
pgbovine opened this issue Jun 25, 2017 · 1 comment
Open

Parameter mutations within functions are not shown #23

pgbovine opened this issue Jun 25, 2017 · 1 comment
Labels

Comments

@pgbovine
Copy link

it seems like parameters being reassigned inside a function aren't reflected in the visualizer

bug report:

Hello,
In the below program after the ptr is loaded with &x,it should point to x,but the visualizer is not doing that ,but the output is right i.e 21 .Can you please explain me why this is happening ?Is it because of somebug or something else?

#include <stdio.h>
 
int fun(int ptr[])
{
   int x = 21;
 
   // size of a pointer is printed
   printf("sizeof(ptr) = %d\n", sizeof(ptr));
 
   // This allowed because ptr is a pointer, not array
   ptr = &x;
 
   printf("*ptr = %d ", *ptr);
 
   return 0;
}
int main()
{
   int arr[] = {10, 20, 30, 40, 50, 60};
   fun(arr);
   return 0;
}
@pgbovine
Copy link
Author

pgbovine commented Dec 7, 2018

Another related bug report:

Hello Philip!
I think that there is a small bug in the C Tutor. If I try the execution of the following code:

#include <stdio.h>
void funcionValor(int a, int b); /*prototipo*/
int main() {
   int x = 2;
   int y = 5;
   funcionValor(x, y);
   return 0;
}

void funcionValor(int a, int b) {
   //printf("%d\t, %d\n", a, b); // <-- uncomment and IT WORKS
   a=0;
   b=0;
   return;
}

The value of a and b don't change in the visualization of the stack. But if I put the previous line printf("%d\t, %d\n", a, b); then it's ok.


PG note: WOW that's weird, if you do a printf beforehand, then the visualizer DOES UPDATE properly, whoa whoa whoa!!!

@pythontutor-dev pythontutor-dev transferred this issue from another repository Jun 28, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants