We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Lcc will compile this code incorrectly, making the pointer in the struct iter_obj passed to iterate become NULL when it really isn't supposed too.
#include <stdio.h> struct iter_obj { void *iterable; }; #define new_iter_obj(iter) {iter} void *array_item(int index, void *iterable) { if (index < 10) { return (void *) &(((int *) iterable)[index]); } else { return NULL; } } void iterate(struct iter_obj *obj) { void *tmp; int index = 0; /* obj->iterable == NULL, but it should point to countdown in main */ while ((tmp = array_item(index, obj->iterable)) != NULL) { printf("%d\n", *((int *) tmp)); index++; } } int main() { int countdown[10] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; /* cd_iter.iterable == countdown */ struct iter_obj cd_iter = new_iter_obj((void *) countdown); iterate(&cd_iter); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Lcc will compile this code incorrectly, making the pointer in the struct iter_obj passed to iterate become NULL when it really isn't supposed too.
The text was updated successfully, but these errors were encountered: