Bug 8537 – Warnings page is outdated

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-11T12:07:00Z
Last change time
2012-09-02T07:06:37Z
Assigned to
nobody
Creator
maxim

Comments

Comment #0 by maxim — 2012-08-11T12:07:22Z
Page http://dlang.org/warnings.html seems to be outdated: It states, that 'length' inside array subscript denotes array's length and that compiler adds assert(0) after loops. However, following code import std.stdio; void main() { char[10] a; int length = 4; writeln(a[length-1]); } int bar(int k, int[] Collection) { foreach(int x; Collection) { if (x == k) return x+1; } } int foo(int i) { return i; return i + 1; } generates errors: hello.d(7): Error: ScopeDsymbol hello.__anonymous.__anonymous.__anonymous using 'length' inside [ ] is deprecated, use '$' instead hello.d(7): Warning: array 'length' hides other 'length' name in outer scope hello.d(10): Error: function hello.bar no return exp; or assert(0); at end of function hello.d(22): Warning: statement is not reachable It indicates that parts dealing with 'length' and assert(0) need be removed from http://dlang.org/warnings.html.
Comment #1 by clugdbug — 2012-08-13T08:23:44Z
Incidentally the 'implicit conversion' warning section is out-of-date too. The statement: "D follows the C and C++ rules regarding default integral promotion in expressions." should be clarified with a mention of D's range propagation, which dramatically reduces the number of false alarms.
Comment #2 by maxim — 2012-09-02T07:06:37Z
Pull request was accepted, issue is closed.