-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid char pointer deference behavior #165
Comments
The test code in the issue #181 makes me think of this issue, and I add the following int main() {
strcpy(a, "DATA");
data_t *data = malloc(sizeof(data_t));
init_data(data, a);
char *raw = data->raw;
printf("%c\n", a[0]);
printf("%c\n", raw[0]);
printf("%c\n", data->raw[0]);
+ printf("%c\n", *data->raw);
+ printf("raw = %x\n", raw);
+ printf("data->raw = %x\n", data->raw);
+ printf("&raw[0] = %x\n", &raw[0]);
+ printf("&data->raw[0] = %x\n", &data->raw[0]);
+ printf("data = %x\n", data);
+ printf("&data[0] = %x\n", &data[0]);
free(data);
return 0;
}
It is obvious that After observing the code snippets in this comment and the comment in the issue #181, I think the potential bug is that using arrow operator and subscripting operator ( In this comment, For my comment in the issue (#181) , the statement |
After using |
Considering the following code:
Using gcc to compile the program and run it, it would output:
But using shecc, it would output:
This happens because of the incorrect deference assembly code.
The text was updated successfully, but these errors were encountered: