Skip to content
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

Fix vector example #249

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Fix vector example #249

merged 2 commits into from
Sep 9, 2024

Conversation

DutChen18
Copy link
Member

Fixed two issues that are made apparent by the following program:

#include <iostream>

class Obj {};

[[cheerp::genericjs]]
int webMain() {
	std::vector<Obj*> vec;

	vec.push_back(new Obj); // [1]

	std::cout << (int)vec[0] << std::endl;

	if (vec[0] == new Obj) { // [2]
		std::cout << "IDENTICAL" << std::endl;
	} else {
		std::cout << "NOT IDENTICAL" << std::endl;
	}

	return 0;
}

At [1], the call to push_back (a wasm function) should produce a diagnostic because it takes a reference to a pointer.

At [2], the if statement is compiled down to a select instruction, and the strings passed to operator<< are in linear memory. But PA did not follow the operands and would not discover the strings to be in linear memory.

@DutChen18 DutChen18 requested a review from yuri91 September 9, 2024 13:37
@yuri91 yuri91 merged commit 59309ae into master Sep 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants