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

Referring to an object outside of its lifetime. #561

Open
h0nzZik opened this issue Aug 29, 2019 · 0 comments
Open

Referring to an object outside of its lifetime. #561

h0nzZik opened this issue Aug 29, 2019 · 0 comments

Comments

@h0nzZik
Copy link
Contributor

h0nzZik commented Aug 29, 2019

This program,

int main() {
	int *p;
	{
		int x = 1;
		p = &x;
	}
	(*p)--;
}

when compiled as a C program, prints the message:

out-of-scope.c:7:3: warning: Referring to an object outside of its lifetime. (Undefined behavior)

However, when compiled as a C++ program, no error is printed and it gets stuck with

`readBytes-aux(_,_,_,_)_CPP-EXECUTION-IO`(loc(obj(#token("4","Int"),#token("4","Int"),auto(#token("0    ","Int"))),#token("3","Int")),#token("4","Int"),`.List`(.KList),tcpp(quals(`.Set`(.KList)),`.Set`(.K    List),`int_CPP-TYPING-SYNTAX`(.KList)))

at the top of the k cell.

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

No branches or pull requests

1 participant