-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dstep not converting const T x[]
to const (T)* x
#85
Comments
Could you give an example that reproduces this bug? E.g. a code snippet with the problematic types? |
An example is converting a function like this:
The output you get is this:
|
Works for me on master. Very likely that I have accientally fixed it as a side effect of a35b6ea |
On master it converts:
to
@Dicebot, @dataPulverizer |
@ciechowoj, yes I think it needs to translate the C arrays to pointers. A D array is twice as large as a pointer (the extra length as you mentioned). |
I'm trying to fix this, don't you know what the following comment from
|
It is an old comment from me and I think it is wrong - I didn't know at the time of writing it that |
(but original use case I had was for global extern variables, not for function parameters - please check if ABI is different there) |
Hmm, I do not know at the moment how to check it other way than experimentally. // lib.c
const int tab[] = {
42,
42,
24
}; Segmentation fault. // test.d
extern (C) extern __gshared const (int)[] tab;
int main()
{
import std.stdio;
writeln(tab[0]);
return 0;
} Segmentation fault. // test.d
extern (C) extern __gshared const (int)* tab;
int main()
{
import std.stdio;
writeln(tab[0]);
return 0;
} 42 // test.d
extern (C) extern __gshared const (int)[3] tab;
int main()
{
import std.stdio;
writeln(tab[0]);
return 0;
} It seems like the only way to translate this is to compute the size of an array somehow during translation... |
Hmm, worse if the array is declared with
|
On forum.dlang they suggested to declare an one element array instead. |
What if you make it a pointer? |
Fix #85: dstep not converting `const T x[]` to `const (T)* x`.
Sorry for my silence on this I think the conversion |
Segmentation fault.
|
Hm, how about |
|
I suppose we could fix it for the time being by declaring an array with 0 or 1 length. |
Is this something that needs fixing in D itself? Is the inability to consistently allow the replacement of |
@dataPulverizer sounds like a bug to me. |
Just for curiosity, do you have an idea how it could be correctly solved/handled in D? |
@ciechowoj nothing at all comes to mind |
Not sure if it's related. On OS X, DMD outputs the |
I am currently working with dstep version 0.2.2 and found that:
const T x[]
is not currently being converted toconst (T)* x
. It says<unimplemented>
. I am currently doing a find and replace toconst T *x
in the original script which gives the desired output but it would be nice not to have to do that.Thanks a lot for this very useful tool.
The text was updated successfully, but these errors were encountered: