Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 11, 2011 [Issue 5980] New: Can't pass __traits value as const(char)* | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5980 Summary: Can't pass __traits value as const(char)* Product: D Version: future Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: Jesse.K.Phillips+D@gmail.com CC: Jesse.K.Phillips+D@gmail.com --- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2011-05-11 11:03:10 PDT --- This worked in 2.052 but is failing to compile in the latest beta for 2.053. This is used by LuaD. struct A { int a; } void main() { foreach(field; __traits(allMembers, A)) { usefield(field); } } void usefield(const(char)* foo) { } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] Can't pass __traits value as const(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 --- Comment #1 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2011-05-11 11:09:35 PDT --- Oh and the error message: break.d(7): Error: cannot implicitly convert expression (field) of type const(im mutable(char)[]) to const(char)* -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] Can't pass __traits value as const(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm@gmail.com --- Comment #2 from kennytm@gmail.com 2011-05-11 11:23:13 PDT --- (In reply to comment #0) > This worked in 2.052 but is failing to compile in the latest beta for 2.053. This is used by LuaD. > > struct A { > int a; > } > void main() { > foreach(field; __traits(allMembers, A)) > { > usefield(field); > } > > } > > void usefield(const(char)* foo) { > } Why not use 'usefield(field.ptr)'? I don't think implicitly converting an array to a pointer is expected. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] Can't pass __traits value as const(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 --- Comment #3 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2011-05-11 11:33:58 PDT --- Well I invasion the code being expanded to: void main() { usefield("a"); } Which is expected to implicitly convert to const(char)* -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] Can't pass __traits value as const(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrei@metalanguage.com --- Comment #4 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-05-11 12:29:17 PDT --- The conversion of a string literal to a immutable(char)* has been disallowed, and for arguably good reasons. You may want to use a.ptr instead. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] foreach element of a type tuple of string literals is not implicitly convertible to immutable(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Can't pass __traits value |foreach element of a type |as const(char)* |tuple of string literals is | |not implicitly convertible | |to immutable(char)* --- Comment #5 from kennytm@gmail.com 2011-05-11 12:32:41 PDT --- Actually it's a problem in foreach-ing a TupleExp of StringExp, not __traits. I changed the title to reflect that. ------------------------------------- template TypeTuple(T...) { alias T TypeTuple; } void main() { alias TypeTuple!"1" T; usefield(T[0]); // ok foreach (j; T) usefield(j); // error on 2.053 } void usefield(const(char)* foo) { } ------------------------------------- (Still, I think it's better to use .ptr then relying on it the implicit string literal -> pointer conversion.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] foreach element of a type tuple of string literals is not implicitly convertible to immutable(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 --- Comment #6 from kennytm@gmail.com 2011-05-11 12:33:31 PDT --- (In reply to comment #4) > The conversion of a string literal to a immutable(char)* has been disallowed, and for arguably good reasons. You may want to use a.ptr instead. Really? Jesse's example in comment #3 is still compilable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 11, 2011 [Issue 5980] foreach element of a type tuple of string literals is not implicitly convertible to immutable(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 --- Comment #7 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-05-11 12:44:19 PDT --- I must be confused, sorry. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 07, 2011 [Issue 5980] foreach element of a type tuple of string literals is not implicitly convertible to immutable(char)* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5980 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |FIXED --- Comment #8 from yebblies <yebblies@gmail.com> 2011-09-07 13:56:12 EST --- Fixed in 2.055 beta, probably the same as issue 6220. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation