[Issue 8886] [CTFE] a check failure of memory block inclusion
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 24 10:42:31 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8886
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
CC| |clugdbug at yahoo.com.au
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2012-10-24 10:42:30 PDT ---
This behaviour is intentional. The relevant line is:
return a.length &&
b.ptr >= a.ptr &&
b.ptr + b.length <= a.ptr + a.length;
This means:
return (a.length &&
b.ptr >= a.ptr) &&
b.ptr + b.length <= a.ptr + a.length;
If the b.ptr < a.ptr, then the first subexpression fails, and because of
short-circuit evaluation, b.ptr + b.length <= a.ptr + a.length is never
evaluated.
What you actually want is:
return a.length &&
(b.ptr >= a.ptr &&
b.ptr + b.length <= a.ptr + a.length);
Now in this particular case, the compiler could recognize e1 && e2 && e3 but it
won't work in general, I think it makes things unpredictable.
Changing to a diagnostic bug.
I'm so disappointed, I went to a lot of trouble to give a good error message
(even using the variable names you used!), and it seems it's still not clear
enough. Any suggestions?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list