www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - casting as char at CT fail

reply "bioinfornatics" <bioinfornatics fedoraproject.org> writes:
Hi,
this time i have so many question about CT …
iws and ibuclaw help me for this.

I stuck currently about a cast at CT -> 
http://www.dpaste.dzfl.pl/1a28a22c

it seem this should works but not…
So if you confirm maybe a report is needed

thanks to everyone
Nov 26 2013
next sibling parent reply Shammah Chancellor <anonymous coward.com> writes:
On 2013-11-26 23:31:14 +0000, bioinfornatics said:

 Hi,
 this time i have so many question about CT …
 iws and ibuclaw help me for this.
 
 I stuck currently about a cast at CT -> http://www.dpaste.dzfl.pl/1a28a22c
 
 it seem this should works but not…
 So if you confirm maybe a report is needed
 
 thanks to everyone
String at compile time seem to be represented as dchar. Also, the loop on bitsPerChar won't work at compile time right now. I think maskTmp = cast(T)((1 << bitsPerChar) - 1); does the same thing though. http://www.dpaste.dzfl.pl/985a2f42 Fails with some weird internal DMD error now though while trying to instantiate the enum. Maybe time for a bug report?
Nov 26 2013
parent reply "bioinfornatics" <bioinfornatics fedoraproject.org> writes:
On Wednesday, 27 November 2013 at 01:22:07 UTC, Shammah 
Chancellor wrote:
 On 2013-11-26 23:31:14 +0000, bioinfornatics said:

 Hi,
 this time i have so many question about CT …
 iws and ibuclaw help me for this.
 
 I stuck currently about a cast at CT -> 
 http://www.dpaste.dzfl.pl/1a28a22c
 
 it seem this should works but not…
 So if you confirm maybe a report is needed
 
 thanks to everyone
String at compile time seem to be represented as dchar. Also, the loop on bitsPerChar won't work at compile time right now. I think maskTmp = cast(T)((1 << bitsPerChar) - 1); does the same thing though. http://www.dpaste.dzfl.pl/985a2f42 Fails with some weird internal DMD error now though while trying to instantiate the enum. Maybe time for a bug report?
ldc2 fail too but error message is better, i think. $ ldc2 BaseTest2.d /usr/include/d/std/range.d(4171): Error: pointer cast from immutable(dchar)* to dchar* is not supported at compile time BaseTest2.d(56): called from here: __r11.front() BaseTest2.d(99): called from here: Base(cast(ubyte)0u, null, cast(ubyte)0u, cast(ubyte)0u, null, null).this(cast(ubyte)4u, "ACGT", [cast(ubyte)0u, cast(ubyte)1u, cast(ubyte)2u, cast(ubyte)3u]) BaseTest2.d(101): Error: function BaseTest2.Base!(ubyte, dchar).Base.encode (const(immutable(dchar)[]) word) const is not callable using argument types (string)
Nov 26 2013
next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
Does std.conv.to have a better behavior?
Nov 26 2013
parent "bioinfornatics" <bioinfornatics fedoraproject.org> writes:
On Wednesday, 27 November 2013 at 06:34:27 UTC, Philippe Sigaud 
wrote:
 Does std.conv.to have a better behavior?
http://www.dpaste.dzfl.pl/6a5d8c72 it segfault
Nov 27 2013
prev sibling parent Shammah Chancellor <anonymous coward.com> writes:
On 2013-11-27 06:06:49 +0000, bioinfornatics said:

 On Wednesday, 27 November 2013 at 01:22:07 UTC, Shammah Chancellor wrote:
 On 2013-11-26 23:31:14 +0000, bioinfornatics said:
 
 Hi,
 this time i have so many question about CT …
 iws and ibuclaw help me for this.
 
 I stuck currently about a cast at CT -> http://www.dpaste.dzfl.pl/1a28a22c
 
 it seem this should works but not…
 So if you confirm maybe a report is needed
 
 thanks to everyone
String at compile time seem to be represented as dchar. Also, the loop on bitsPerChar won't work at compile time right now. I think maskTmp = cast(T)((1 << bitsPerChar) - 1); does the same thing though. http://www.dpaste.dzfl.pl/985a2f42 Fails with some weird internal DMD error now though while trying to instantiate the enum. Maybe time for a bug report?
ldc2 fail too but error message is better, i think. $ ldc2 BaseTest2.d /usr/include/d/std/range.d(4171): Error: pointer cast from immutable(dchar)* to dchar* is not supported at compile time BaseTest2.d(56): called from here: __r11.front() BaseTest2.d(99): called from here: Base(cast(ubyte)0u, null, cast(ubyte)0u, cast(ubyte)0u, null, null).this(cast(ubyte)4u, "ACGT", [cast(ubyte)0u, cast(ubyte)1u, cast(ubyte)2u, cast(ubyte)3u]) BaseTest2.d(101): Error: function BaseTest2.Base!(ubyte, dchar).Base.encode (const(immutable(dchar)[]) word) const is not callable using argument types (string)
The cast is unnecessary just do the assignment using dchars. Even with that fixed though, there is annother problem as seen in my dpaste.
Nov 27 2013
prev sibling parent reply "Kenji Hara" <k.hara.pg gmail.com> writes:
On Tuesday, 26 November 2013 at 23:31:16 UTC, bioinfornatics 
wrote:
 Hi,
 this time i have so many question about CT …
 iws and ibuclaw help me for this.

 I stuck currently about a cast at CT -> 
 http://www.dpaste.dzfl.pl/1a28a22c

 it seem this should works but not…
 So if you confirm maybe a report is needed

 thanks to everyone
I found two compiler issues: https://d.puremagic.com/issues/show_bug.cgi?id=11627 https://d.puremagic.com/issues/show_bug.cgi?id=11629 Kenji Hara
Nov 27 2013
parent Shammah Chancellor <anonymous coward.com> writes:
On 2013-11-28 03:40:25 +0000, Kenji Hara said:

 On Tuesday, 26 November 2013 at 23:31:16 UTC, bioinfornatics wrote:
 Hi,
 this time i have so many question about CT …
 iws and ibuclaw help me for this.
 
 I stuck currently about a cast at CT -> http://www.dpaste.dzfl.pl/1a28a22c
 
 it seem this should works but not…
 So if you confirm maybe a report is needed
 
 thanks to everyone
I found two compiler issues: https://d.puremagic.com/issues/show_bug.cgi?id=11627 https://d.puremagic.com/issues/show_bug.cgi?id=11629 Kenji Hara
Kenji you are awesome! Also, I had got his code working to a point: http://www.dpaste.dzfl.pl/985a2f42 and got another compiler bug. /opt/compilers/dmd2/include/std/range.d(4220): Error: Internal Compiler Error: CTFE literal Tuple(void, void)._expand_field_0 dmd: ctfeexpr.c:359: Expression* copyLiteral(Expression*): Assertion `0' failed. Seems to happen at the end while trying to instantiate the enum. I am having trouble turning it into a reduced test case. Can't find the source of the problem. Here's the full snippet: http://www.dpaste.dzfl.pl/fork/985a2f42 Thanks for looking into this!
Nov 28 2013