March 17, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 Sobirari Muhomori <dfj1esp02@sneakemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |industry -- |
April 20, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 Jon Degenhardt <jrdemail2000-dlang@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jrdemail2000-dlang@yahoo.co | |m --- Comment #62 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> --- Hit this in my code. My bug, but would have been useful if the compiler had informed me there was a signed vs unsigned comparison. Here's the reduced form of what was happening in my code: void main() { int i = -1; size_t j = 0; assert(i < j); } This code compiles, and the assert fails. Except that I didn't have the assert, just the test. -- |
August 30, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 --- Comment #63 from Dominikus Dittes Scherkl <dominikus@scherkl.de> --- (In reply to Dominikus Dittes Scherkl from comment #58) > So why don't we change to something that simply always works? I have meanwhile improved my solution to something more straight forward, with less superfluous casting, and now that the frontend is written in D, it should be no problem to integrate it in the compiler: int opCmp(T, U)(const(T) a, const(U) b) pure @safe @nogc nothrow if(isIntegral!T && isIntegral!U && is(Unqual!T != Unqual!U)) { static if(isSigned!T && isUnsigned!U && T.sizeof <= U.sizeof) return (a < 0) ? -1 : opCmp(cast(U)a, b); else static if(isUnsigned!T && isSigned!U && T.sizeof >= U.sizeof) return (b < 0) ? 1 : opCmp(a, cast(T)b); else // do interger propagation as ever: return opCmp(cast(CommonType!(T, U))a, cast(CommonType!(T, U))b); } -- |
September 03, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 --- Comment #64 from Andrei Alexandrescu <andrei@erdani.com> --- Time to finalize this. We should be fine with a slight loss in efficiency in mixed sign compare. What active PRs are open at this time? -- |
October 10, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 thomas.bockman@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thomas.bockman@gmail.com --- Comment #65 from thomas.bockman@gmail.com --- (In reply to Andrei Alexandrescu from comment #64) > We should be fine with a slight loss in efficiency in > mixed sign compare. The previously agreed upon solution was to default to warning about each signed/unsigned comparison, but omit the warning if VRP could prove it to be safe. There is no loss of run-time efficiency that way, but some code will break and require an explicit cast to fix. Are you suggesting that we should just insert an extra comparison to zero as needed, instead? I'd support that, but I don't know how others (including Walter Bright) would feel about it. The real performance impact should be immeasurably small in nearly all cases (especially with the VRP upgrades discussed below). > What active PRs are open at this time? My DMD #5229 is a continuation of Lionello's work toward improving VRP sufficiently to minimize code breakage: https://github.com/dlang/dmd/pull/5229 However, it's stuck pending a resolution to another DMD bug: https://issues.dlang.org/show_bug.cgi?id=15585 If #5229 ever gets pulled, one more tricky VRP- related follow-up is required to make the compiler smart enough. After that, actually fixing this bug is trivial: I've had that patch ready to go for about a year now, but can't submit it until the VRP stuff is straightened out because it causes too much breakage. -- |
October 10, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 --- Comment #66 from thomas.bockman@gmail.com --- Oops! That's the wrong DMD bug. This is the one I actually meant: https://issues.dlang.org/show_bug.cgi?id=14835 -- |
October 12, 2016 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 --- Comment #67 from Andrei Alexandrescu <andrei@erdani.com> --- (In reply to thomas.bockman from comment #66) > Oops! That's the wrong DMD bug. This is the one I > actually meant: > https://issues.dlang.org/show_bug.cgi?id=14835 That makes sense. Thanks, and for the update as well. -- |
April 21, 2017 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=12919 -- |
December 15, 2017 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh@quickfur.ath.cx -- |
December 15, 2017 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=259 --- Comment #68 from hsteoh@quickfur.ath.cx --- Whoa. This is approaching 12 years now, and even has a preapproved pull. When will the fix actually get merged?! -- |
Copyright © 1999-2021 by the D Language Foundation