digitalmars.D - redundant storage class 'const
- Paul D Anderson (29/29) Jul 05 2014 The getValueX functions below differ only in the number and
- bearophile (12/14) Jul 05 2014 The situation with accepting or not accepting those tags attached
- Timon Gehr (3/6) Jul 05 2014 While there are some oddities there, many (most?) reports in that issue
- bearophile (6/7) Jul 05 2014 Take a look at the report date, Timon: 2010-03-11, in the
The getValueX functions below differ only in the number and
placing of the keyword 'const'.
The compiler rejects the first (with 'const const' prefix), as
expected (Error: redundant storage class 'const').
The second (with prefix 'const', suffix 'const') is accepted. It
looks strange but is apparently valid code (cf Bugs 4070 & 9020).
The fourth (with multiple 'const' suffixed) does not generate an
error. This looks like a bug to me. Is it?
public class cls {
private int _value;
this(int value) {
_value = value;
}
// public const const int getValue1() { // Error: redundant
storage class 'const'
// return _value;
// }
public const int getValue2() const { // No error
return _value;
}
public int getValue3() const { // No error
return _value;
}
public int getValue4() const const const { // No error
return _value;
}
}
As a side note, the error message on the first function is
succinct and comprehensible. We can probably close Bug 9422.
Jul 05 2014
Paul D Anderson:The fourth (with multiple 'const' suffixed) does not generate an error. This looks like a bug to me. Is it?The situation with accepting or not accepting those tags attached to functions is a terrible mess since several years, at ridiculous levels. Fixing that mess will cause lot of D code to break, assuming someone someday will want to fix that awful mess, but I can't assume that any more. Look at this Issue https://d.puremagic.com/issues/show_bug.cgi?id=3934 for some humorous examples fit more for the Monty Python and the Flying Circus than a serious language. Bye, bearophile
Jul 05 2014
On 07/06/2014 12:39 AM, bearophile wrote:Look at this Issue https://d.puremagic.com/issues/show_bug.cgi?id=3934 for some humorous examples fit more for the Monty Python and the Flying Circus than a serious language.While there are some oddities there, many (most?) reports in that issue are invalid. I'd have preferred separate issues for unrelated cases.
Jul 05 2014
Timon Gehr:I'd have preferred separate issues for unrelated cases.Take a look at the report date, Timon: 2010-03-11, in the meantime I have learnt a thing or two regarding reporting compiler bugs :-) Bye, bearophile
Jul 05 2014








"bearophile" <bearophileHUGS lycos.com>