D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 123 - Use of function, modulus, and dollar sign (length) fails to compile with static and const
Summary: Use of function, modulus, and dollar sign (length) fails to compile with stat...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: Walter Bright
URL:
Keywords: link-failure
Depends on:
Blocks:
 
Reported: 2006-05-01 20:39 UTC by Alex
Modified: 2014-02-15 13:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Alex 2006-05-01 20:39:33 UTC
uint intRes()
{
	return 4;
}

int main()
{
	static const char []foo = "abc123";
	//everything works as expected if static and const are removed.
	writefln( "%c", foo[intRes() % $] );
	
	return 0;
}

linking fails:
main.obj(main)
 Error 42: Symbol Undefined _Dmain8__dollark
--- errorlevel 1
Comment 1 Derek Parnell 2006-05-01 21:25:07 UTC
This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char [6]foo = "abc123";
void main()
{
    writefln( foo[intRes() % length] );
}
// --------------


This fails...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char []foo = "abc123";
void main()
{
    writefln( foo[intRes() % length] );
}
// --------------

This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char []foo = "abc123";
void main()
{
    writefln( foo[intRes() % foo.length] );
}
// --------------

This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
char []foo = "abc123";
void main()
{
    writefln( foo[intRes() % length] );
}
// --------------

This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char []foo = "abc123";
void main()
{
    writefln( foo[4 % length] );
}
// --------------
Comment 2 Thomas Kühne 2006-05-14 23:30:24 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail@puremagic.com schrieb am 2006-05-02:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=123

> uint intRes()
> {
>         return 4;
> }
>
> int main()
> {
>         static const char []foo = "abc123";
>         //everything works as expected if static and const are removed.
>         writefln( "%c", foo[intRes() % $] );
>
>         return 0;
> }
>
> linking fails:
> main.obj(main)
>  Error 42: Symbol Undefined _Dmain8__dollark
> --- errorlevel 1

Added to DStress as
http://dstress.kuehne.cn/run/l/length_10_A.d
http://dstress.kuehne.cn/run/l/length_10_B.d
http://dstress.kuehne.cn/run/l/length_10_C.d
http://dstress.kuehne.cn/run/l/length_10_D.d
http://dstress.kuehne.cn/run/l/length_10_E.d
http://dstress.kuehne.cn/run/l/length_10_F.d
http://dstress.kuehne.cn/run/l/length_10_G.d
http://dstress.kuehne.cn/run/l/length_10_H.d
http://dstress.kuehne.cn/run/l/length_10_I.d
http://dstress.kuehne.cn/run/l/length_10_J.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFEaA1P3w+/yD4P9tIRAsRQAJwI6J1XBy9GFKb/aeEj9eVngxxEvwCfXC8x
b90XNHeomnB2yRBYr2rOnVU=
=y75o
-----END PGP SIGNATURE-----

Comment 3 Walter Bright 2006-06-20 02:20:10 UTC
Fixed DMD 0.161
Comment 4 github-bugzilla 2012-05-11 18:58:10 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a1e42aa8cb31cd218d98c5685d8848de264ddf51
Add a new DISABLED option for tests

Sometimes is useful to be able to add tests even when they don't pass.
Being able to do so, makes life easier for people wanting to fix the bug
(they have the test right there) and ensures people don't forget to add
test cases just because it would break the auto-tester.

Now tests can have a DISABLED option which should have a reason why the
test was disabled. For example:
// DISABLED: bug 123 is still not fixed

When a test is disabled, a special message is printed, for example:
 !!! runnable/bug123.d          () [DISABLED: bug 123 is still not fixed]