www.digitalmars.com         C & C++   DMDScript  

D - constant evaluation with conditional expression

reply Yung-Hei, Lee <undoc mail.shinbiro.com> writes:
	enum {A=1}
	enum {B=A?0:1}

This simple constant assignment does not work.
This snippet generate following error message.

	"non-constant expression 1 ? 0 : 1"

It obviously is constant expression, isn't it?

	enum {A=1}
	enum {B=A+1}

This works.

It looks that conditioanl expression never evaluated to constant value.

The same is true for "const" attribute.

	const int i = 1;
	const int j = i?0:1;

This code generates the same error message.
May 19 2003
parent "Walter" <walter digitalmars.com> writes:
Yes, it should work. I'll add it to the bug list.
May 20 2003