www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Segfaults on Constant Definitions

reply John Reimer <brk_6502 yahoo.com> writes:
OS:         
Gentoo Linux with Kernel 2.6

D Compiler: 
dmd version 0.113

CODE:





















OUTPUT:
test4(8):50*50 is not an expression
test4(9):a1 - 1 * a2 - 1 is not an expression
Segmentation fault

PROBLEM:

The compiler balks on calculated constant expressions. In arrays 1-3, take
out the "4*" in the array dimension to get a different set of errors (no
segfault).  Comment out the individual array declarations to get more
complaints from the compiler.  Furthermore, remove all array declarations
to get /no/ complaints from the compiler. The compiler error only shows up
when you attempt to use the constants.

Since const values are the only replacement solution for the C
preprocessor "#define", why are these expressions incalculable?

Win32 version not tested!

- John R.
Feb 20 2005
next sibling parent zwang <nehzgnaw gmail.com> writes:
John Reimer wrote:
 Win32 version not tested!
 
 - John R.
dmd win32 fails too.
Feb 20 2005
prev sibling next sibling parent reply Kris <Kris_member pathlink.com> writes:
In article <pan.2005.02.20.14.41.58.234018 yahoo.com>, John Reimer says...
OS:         
Gentoo Linux with Kernel 2.6

D Compiler: 
dmd version 0.113

CODE:





















OUTPUT:
test4(8):50*50 is not an expression
test4(9):a1 - 1 * a2 - 1 is not an expression
Segmentation fault

PROBLEM:

The compiler balks on calculated constant expressions. In arrays 1-3, take
out the "4*" in the array dimension to get a different set of errors (no
segfault).  Comment out the individual array declarations to get more
complaints from the compiler.  Furthermore, remove all array declarations
to get /no/ complaints from the compiler. The compiler error only shows up
when you attempt to use the constants.

Since const values are the only replacement solution for the C
preprocessor "#define", why are these expressions incalculable?

Win32 version not tested!

- John R.
consts are sometimes astonishingly weak in D. I bet it would be fine if you used enum instead - Kris
Feb 23 2005
parent reply John Reimer <brk_6502 yahoo.com> writes:
Kris wrote:

 consts are sometimes astonishingly weak in D. I bet it would be fine if you
used
 enum instead
 
 - Kris
 
 
Thanks, Kris. If there's so much trouble with const's, I think this should be fixed. I'll see what enum can do for me. I guess a template could even be a solution, if not overkill. - John R.
Feb 23 2005
parent kris <fu bar.org> writes:
John Reimer wrote:
 Kris wrote:
 
 consts are sometimes astonishingly weak in D. I bet it would be fine 
 if you used
 enum instead

 - Kris
Thanks, Kris. If there's so much trouble with const's, I think this should be fixed.
No question about it :) Frankly, I'd prefer Walter to remove const completely until he's spent some time thinking about how to correctly implement read-only variables, and the related ROM-based reference data. I doubt that will happen though. - Kris
Feb 23 2005
prev sibling parent =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.THISISSPAM.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Reimer wrote:
| OS:
| Gentoo Linux with Kernel 2.6
|
| D Compiler:
| dmd version 0.113
|
| CODE:




















|
| OUTPUT:
| test4(8):50*50 is not an expression
| test4(9):a1 - 1 * a2 - 1 is not an expression
| Segmentation fault

Added to DStress as
http://dstress.kuehne.cn/run/const_14.d

Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCMp3v3w+/yD4P9tIRAjfVAJ93J6BZgYsn2gTxA9Xvsve3cKq3/wCgsVjA
KJzlRlQ6/lvX1/LQXEfkRl0=
=HxV0
-----END PGP SIGNATURE-----
Mar 11 2005