[Issue 1486] New: Can't implicitly convert char[][] to const(char)[][]

Bill Baxter dnewsgroup at billbaxter.com
Fri Sep 7 23:16:42 PDT 2007


Bill Baxter wrote:
> Bruno Medeiros wrote:
>> d-bugmail at puremagic.com wrote:
>>> http://d.puremagic.com/issues/show_bug.cgi?id=1486
>>>
>>>            Summary: Can't implicitly convert char[][] to const(char)[][]
>>>            Product: D
>>>            Version: 2.004
>>>           Platform: PC
>>>         OS/Version: Windows
>>>             Status: NEW
>>>           Severity: normal
>>>           Priority: P2
>>>          Component: DMD
>>>         AssignedTo: bugzilla at digitalmars.com
>>>         ReportedBy: reiner.pope at gmail.com
>>>
>>>
>>> The following code fails to compile, with error "cannot implicitly 
>>> convert
>>> expression (a) of type char[][] to const(char)[][]". However, it 
>>> appears to be
>>> a valid operation.
>>>
>>> void main() {
>>>     char[][] a;
>>>     string[] b = a;
>>> }
>>>
>>>
>>
>> Finally! I actually knew about this bug some time ago (2-4 months), 
>> when I updated some of my D shell scripts to D 2.0. I purposefully 
>> didn't report since I wanted to see how long it would take until 
>> someone else did. It seemed such a common problem (I have very little 
>> D code written, yet I stumbled upon it quickly), that I'm somewhat 
>> surprised it took this long for someone to report it. Isn't there that 
>> many people using D2.0 features or what?
>>
> 
> I'd like to do more in D 2.0, but if the libraries I need aren't ported, 
> it's either spend a lot of time porting them myself, or stick with D 1. 
>  Right now D1 seems the better option.  But since D1 isn't getting new 
> features I suspect there will come a point when D2 gets something so 
> utterly cool that it's worth doing whatever it takes to use it, 
> including maintaining private 2.0 forks of other people's libraries.  Of 
> course by then they might have already ported... so I might as well wait.

Oh, and I should also mention that the one thing I really wanted const 
for originally (passing structs as const ref), still crashes the 
compiler in 2.004.

It was demonstrated pretty clearly in the ray-tracer someone ported from 
C++ to D that passing structs by value has a significantly detrimental 
impact on performance.  Passing them by plain ref improves the 
performance but it sends the wrong message to the user and also prevents 
use with non-l-values such as struct literals.

--bb


More information about the Digitalmars-d-bugs mailing list