[Issue 6305] String literals don't always have a 0 appended to them
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 13 12:28:01 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6305
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |schveiguy at yahoo.com
Resolution| |INVALID
--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-07-13 12:22:48 PDT ---
Actually, I did have a D1 compiler laying around. And I figured out the issue.
The issue is D1's type inference treats string literal types as char[N] where N
is a uint. Note that D2's type inference treats string literals as
immutable(char)[]. So the issue is that you are not declaring a type, and D is
assuming you meant it to be a fixed-sized array. So the literal *does* have a
zero, but it is copied into your declared fixed-sized arrays in the global
segment without the zero.
I figured it out by doing:
pragma(msg, typeof(s1).stringof);
which prints:
char[4u];
If you do this:
const string s1 = "abcd", s2 = "EFG", s3 = "h";
Then it works as you expect.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list