Comment #0 by bearophile_hugs — 2011-06-02T07:21:24Z
With DMD 2.053 this program:
void main() {
__gshared int[1][1] foo;
}
Gives:
test.d(2): Error: cannot implicitly convert expression (0) of type int to int[1u][1u]
Comment #1 by ibuclaw — 2011-06-27T14:09:17Z
Similarly, this should be valid code.
void main()
{
__thread int[1][1] foo;
}
and this shouldn't try to assign a default initialiser at all!
void main()
{
extern int[1][1] foo;
}
Comment #2 by andrej.mitrovich — 2013-03-18T08:00:02Z
(In reply to comment #0)
> With DMD 2.053 this program:
>
>
> void main() {
> __gshared int[1][1] foo;
> }
This is fixed by Issue 8041.
(In reply to comment #1)
> Similarly, this should be valid code.
>
> void main()
> {
> __thread int[1][1] foo;
> }
__thread has since been removed.
> and this shouldn't try to assign a default initializer at all!
>
> void main()
> {
> extern int[1][1] foo;
> }
What exactly are the semantics of this? It has D mangling, so where can you define (not declare) foo? I guess you could use mangling hacks such as:
extern(C) int[1][1] D4test4mainFZv3fooG1G1i = [[4]];
void main()
{
extern int[1][1] foo;
assert(foo == [[4]]);
}
Is this ok though?
Note that declaring `extern(C) int[1][1] foo;` does already work.
Comment #3 by andrej.mitrovich — 2013-03-18T08:10:41Z
(In reply to comment #2)
> (In reply to comment #0)
> > With DMD 2.053 this program:
> >
> >
> > void main() {
> > __gshared int[1][1] foo;
> > }
>
> This is fixed by Issue 8041.
>
> (In reply to comment #1)
> > Similarly, this should be valid code.
> >
> > void main()
> > {
> > __thread int[1][1] foo;
> > }
>
> __thread has since been removed.
>
> > and this shouldn't try to assign a default initializer at all!
> >
> > void main()
> > {
> > extern int[1][1] foo;
> > }
>
> What exactly are the semantics of this? It has D mangling, so where can you
> define (not declare) foo? I guess you could use mangling hacks such as:
>
> extern(C) int[1][1] D4test4mainFZv3fooG1G1i = [[4]];
>
> void main()
> {
> extern int[1][1] foo;
> assert(foo == [[4]]);
> }
>
> Is this ok though?
>
> Note that declaring `extern(C) int[1][1] foo;` does already work.
I don't think it should be valid at all to declare an 'extern' variable/function inside another function. Reasons because of the hairiness as you've described.
Just my opinion though.
Comment #5 by github-bugzilla — 2013-03-19T00:00:47Z