Thread overview
[Issue 6089] New: __gshared with not static 2D array
Jun 27, 2011
Iain Buclaw
Mar 18, 2013
Andrej Mitrovic
Mar 18, 2013
Andrej Mitrovic
Mar 18, 2013
Iain Buclaw
Mar 19, 2013
Walter Bright
June 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6089

           Summary: __gshared with not static 2D array
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-06-02 07:21:24 PDT ---
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]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 27, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6089


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@ubuntu.com


--- Comment #1 from Iain Buclaw <ibuclaw@ubuntu.com> 2011-06-27 14:09:17 PDT ---
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;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6089


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-18 08:00:02 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6089


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|x86                         |All
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com
         OS/Version|Windows                     |All


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-18 08:10:41 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1762

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6089



--- Comment #4 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-03-18 08:11:35 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6089



--- Comment #5 from github-bugzilla@puremagic.com 2013-03-19 00:00:47 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0503a9eea91e05d74d0a2a4701a7cd50b806c98b Fixes Issue 6089 - extern variable should not have an initializer.

https://github.com/D-Programming-Language/dmd/commit/f6adf56c67498de17c5a374a04ab50118cda7cc3 Merge pull request #1762 from AndrejMitrovic/Fix6089

Issue 6089 - extern variable should not have an initializer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6089


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------