March 27, 2013 static enum member of incomplete type, valid or not? | ||||
|---|---|---|---|---|
| ||||
I'd like to get a definite answer to whether the following code is valid or not:
struct S
{
int v = 42;
this(int val) { v = val + 1; }
enum s = S(4);
}
void main()
{
static assert(S.s.v == 5);
}
There's a bug report about it:
http://d.puremagic.com/issues/show_bug.cgi?id=9397
...but according to some of the comments there, the code isn't valid anyway, so it's not a bug.
This question is parallel to C++, where the following is currently invalid:
struct S
{
int v;
static constexpr S s = S{4};
};
...but there's been a proposal to change the wording of the standard that would make the code valid.
| ||||
March 30, 2013 Re: static enum member of incomplete type, valid or not? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to TommiT | On 03/27/2013 01:01 PM, TommiT wrote: > I'd like to get a definite answer to whether the following code is valid > or not: > > struct S > { > int v = 42; > this(int val) { v = val + 1; } > enum s = S(4); > } > > void main() > { > static assert(S.s.v == 5); > } > Valid. > There's a bug report about it: > http://d.puremagic.com/issues/show_bug.cgi?id=9397 > > ...but according to some of the comments there, the code isn't valid > anyway, so it's not a bug. > ... There are no comments that would indicate this. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply