View mode: basic / threaded / horizontal-split · Log in · Help
June 22, 2011
[Issue 6196] New: with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196

          Summary: with statement with single statement breaks linking
          Product: D
          Version: D2
         Platform: Other
       OS/Version: Windows
           Status: NEW
         Severity: normal
         Priority: P2
        Component: DMD
       AssignedTo: nobody@puremagic.com
       ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-06-22 11:05:51 PDT ---
module test;
static import std.stdio;

void main()
{
   with (std.stdio) writeln();
}

OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\DOCUME~1\Andrej\LOCALS~1\Temp\.rdmd\rdmd-test.d-A365FA805A6F8950E12081529066367B\test-d-A365FA805A6F8950E12081529066367B.obj(test-d-A365FA805A6F8950E12081529066367B)
Error 42: Symbol Undefined _D3std5stdio12__T7writelnZ7writelnFZv

This will work:
module test;
static import std.stdio;

void main()
{
   with (std.stdio) { writeln(); }
}

Note how in the next example the first `with` statement has curly braces and
references writeln(), it gets linked in, and the linker errors are gone for the
second `with` statement:

static import std.stdio;

void main()
{
   with (std.stdio) { writeln(); }
   with (std.stdio) writeln();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 22, 2011
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196


bearophile_hugs@eml.cc changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2011-06-22 11:45:22 PDT ---
(In reply to comment #0)
> module test;
> static import std.stdio;
> 
> void main()
> {
>     with (std.stdio) writeln();

My guess is that with() was designed mostly for struct instances, class
instances, and enum instances. I didn't even know you are allowed to use it
with modules.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 24, 2012
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196


SomeDude <lovelydear@mailmetrash.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |lovelydear@mailmetrash.com


--- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-04-24 11:34:18 PDT ---
Compiles and runs fine with 2.059 Win32.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 24, 2012
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-04-24 14:10:20 PDT ---
(In reply to comment #2)
> Compiles and runs fine with 2.059 Win32.

That's not true.

module test;
static import std.stdio;

void main()
{
   with (std.stdio) writeln();
}

$ dmd test.d
> OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test)
Error 42: Symbol Undefined _D3std5stdio12__T7writelnZ7writelnFZv
--- errorlevel 1

Maybe it works on Posix, but it's not working on my win32 system.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196


hsteoh@quickfur.ath.cx changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |hsteoh@quickfur.ath.cx


--- Comment #4 from hsteoh@quickfur.ath.cx 2012-10-27 10:44:14 PDT ---
It doesn't work on Linux 64-bit, git HEAD:

$ dmd test
test.o: In function `_Dmain':
test.d:(.text._Dmain+0x4): undefined reference to
`_D3std5stdio12__T7writelnZ7writelnFZv'
collect2: error: ld returned 1 exit status
--- errorlevel 1

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196



--- Comment #5 from hsteoh@quickfur.ath.cx 2012-10-27 10:47:09 PDT ---
Interestingly enough, if I replace the with() clause with std.stdio.writeln()
(which links without errors) and look at the resulting executable, it does
define _D3std5stdio12__T7writelnZ7writelnFZv.

Which means that the template isn't getting instantiated when used with a
'with' clause, perhaps?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196



--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-27 10:47:27 PDT ---
The symbol is probably not referenced properly or something.

module test;
static import std.stdio;

void main()
{
   std.stdio.writeln("test");  // reference symbol
   with (std.stdio) writeln("test");
}

If you remove the commented line you'll get a linker error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2013
[Issue 6196] with statement with single statement breaks linking
http://d.puremagic.com/issues/show_bug.cgi?id=6196



--- Comment #7 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-18 09:59:11 PST ---
*** Issue 8414 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home