www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5305] New: intrinsic functions have safe stripped of them in release mode.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5305

           Summary: intrinsic functions have  safe stripped of them in
                    release mode.
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: blood.of.life gmail.com


--- Comment #0 from Bernard Helyer <blood.of.life gmail.com> 2010-12-01
16:50:30 PST ---
https://gist.github.com/724508

The code snippet compiles with -release, but not without. In -release mode, the
maths intrinsics have the mangling for  safe removed ('Nf'), and so the linker
chokes on the mangled signature (because libphobos2.a was compiled with
-release.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 01 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5305


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2012-01-20
12:17:17 PST ---
For convenience, here's the example:

import std.math;

T[] map(T, V)(T function(T) f, V[] list)
{
    T[] result = new T[](list.length);

    foreach(k, v; list)
    {
        result[k] = f(v);
    }

    return result;
}

void main()
{
    assert (map!(real, float) (&sqrt, [4.0f, 9.0f]) == [2.0f, 3.0f]);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5305



--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2012-01-20
12:33:25 PST ---
A reduced test case:

  import std.math;
  void map(real function(real) f) { }
  void main() { map(&sqrt); }

What is happening here is that sqrt() is an intrinsic, it doesn't actually
exist in the libphobos2.a. When compiled with -release, the assert() goes away,
and sqrt is never referenced, hence no error.

Without -release, the linker looks for std.math.sqrt, and can't find it because
it's an intrinsic.

The solution is one of:

1. have the compiler complain about attempts to take the address of an
intrinsic

2. add a library version of the intrinsic

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5305


bearophile_hugs eml.cc changed:

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


--- Comment #3 from bearophile_hugs eml.cc 2012-01-21 18:50:09 PST ---
(In reply to comment #2)
 The solution is one of:
 
 1. have the compiler complain about attempts to take the address of an
 intrinsic
 
 2. add a library version of the intrinsic
Is it possible for the D compiler to use the intrinsic in most cases when sqrt is used directly, and give the pointer to a library sqrt when the programmer uses a &sqrt? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 21 2012