Bug 14981 – [REG 2.068.0] Missing nothrow attribute in dbgVerifySorted()

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-30T07:54:00Z
Last change time
2015-11-09T00:29:41Z
Assigned to
nobody
Creator
b2.temp

Comments

Comment #0 by b2.temp — 2015-08-30T07:54:46Z
--- import std.algorithm; import std.container; void main(string[] args) { Array!string letters = ["b","a","c"]; sort(letters[]); } --- compiles this with -debug. out contract of std.range.SortedRange.this `dbgVerifySorted()` is not nothrow ? errors: C:\...\std\range\package.d(7180): Error: 'std.range.SortedRange!(RangeT!(Array!string), "a < b").SortedRange.dbgVerifySorted' is not nothrow C:\...\std\algorithm\sorting.d(982): Error: template instance std.range.assumeSorted!("a < b", RangeT!(Array!string)) error instantiating
Comment #1 by jiki — 2015-09-24T00:33:15Z
*** Issue 15091 has been marked as a duplicate of this issue. ***
Comment #2 by jack — 2015-09-30T04:01:35Z
Comment #3 by schveiguy — 2015-09-30T13:03:57Z
Seems to be fixed in latest head. Not sure where it was fixed, possibly here: https://github.com/D-Programming-Language/phobos/pull/3669
Comment #4 by k.hara.pg — 2015-10-01T01:27:09Z
(In reply to Steven Schveighoffer from comment #3) > Seems to be fixed in latest head. Not sure where it was fixed, possibly here: > > https://github.com/D-Programming-Language/phobos/pull/3669 Yes, it is. As far as I see, the `uniform` and `text` functions are not nothrow, then dbgVerifySorted was also inferred to throwable.
Comment #5 by b2.temp — 2015-11-08T08:35:15Z
it looks like it was not fully fixed, still with -debug: --- import std.algorithm, std.container; void main() { static bool compare(P a, P b) { return a.curColumn < b.curColumn; } Array!P a = make!(Array!P); sort!compare(a[]); } struct P { int curColumn = 0; } --- see http://forum.dlang.org/post/[email protected]
Comment #6 by tobias — 2015-11-08T09:19:54Z
Making dbgVerifySorted a template function fixes this instance. Probably because the compiler will infer it is nothrow.
Comment #7 by schveiguy — 2015-11-08T17:10:38Z
dbgVerifySorted is part of a SortedRange, which is a template. member functions of templates are also allowed to be inferred using the compiler. This is why dbgVerifySorted was fixed in PR by the removal of the RNG (and not adding nothrow specifically). Either this is a compiler bug or somehow the comparison function isn't implied to be nothrow. Note that there's no 'nothrow' in your code, which makes me feel like the compiler is outsmarting itself. I think this is a new bug. Please open a new one, as the original regression was fixed.
Comment #8 by b2.temp — 2015-11-09T00:29:41Z
(In reply to Steven Schveighoffer from comment #7) > dbgVerifySorted is part of a SortedRange, which is a template. member > functions of templates are also allowed to be inferred using the compiler. > > This is why dbgVerifySorted was fixed in PR by the removal of the RNG (and > not adding nothrow specifically). > > Either this is a compiler bug or somehow the comparison function isn't > implied to be nothrow. > > Note that there's no 'nothrow' in your code, which makes me feel like the > compiler is outsmarting itself. > > I think this is a new bug. Please open a new one, as the original regression > was fixed. https://issues.dlang.org/show_bug.cgi?id=15304