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

Issue 13010: use VRP for static asserts #3706

Closed
wants to merge 1 commit into from

Conversation

lionello
Copy link
Contributor

@yebblies
Copy link
Member

static assert( (assert(0), true) );

@lionello
Copy link
Contributor Author

lionello commented Jul 1, 2014

@yebblies Good point :)

Instead, I've followed @9rnsr 's recommendation and am using VRP during constant folding of comparisons. This is actually much nicer: it can be used instead of __traits(valueRange...) to check the range of a variable. It's also less prone to breakage since the range of a variable will only get narrower as the compiler gets smarter.

@lionello
Copy link
Contributor Author

lionello commented Jul 1, 2014

Yeah, this is not right. Fixing.

@yebblies
Copy link
Member

yebblies commented Jul 1, 2014

Doesn't this have the same problem? You still need to evaluate the expression, because evaluating might fail.

@lionello
Copy link
Contributor Author

lionello commented Jul 1, 2014

Constant folding ("optimize") and VRP don't rely on CTFE and don't fully interpret the expression.

@lionello
Copy link
Contributor Author

lionello commented Jul 1, 2014

(Ugh, still fails. Shouldn't do this at 3am.)

@yebblies
Copy link
Member

yebblies commented Jul 2, 2014

Constant folding ("optimize") and VRP don't rely on CTFE and don't fully interpret the expression.

Yes, but they can't fold away the failure even if they know the range of the value it returns.

@lionello
Copy link
Contributor Author

lionello commented Jul 2, 2014

@yebblies I'm not too worried about that case since it can be figured out. I'm more worried about supposedly "dead code" that's being found in Phobos because dchar.max is 0x10FFFF. In real life, dchar can be higher than that.

@andralex
Copy link
Member

ping

@lionello
Copy link
Contributor Author

Needs more tests.

@lionello
Copy link
Contributor Author

Superseded by #5229

@lionello lionello closed this Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants