www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19570] New: pragma(inline) is emitting symbols

https://issues.dlang.org/show_bug.cgi?id=19570

          Issue ID: 19570
           Summary: pragma(inline) is emitting symbols
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

pragma(inline) doesn't seem to work right.

  pragma(inline, true) int foo() { return 10; }

Don't make any call to this function, just put it alone in a source file and
note that it is still emit to the object file (on linux at least).

I understand the compiler may not guarantee that the function was inlined, and
it *may* emit a symbol to the object file _when it's called_, but the basic
semantic promise of the inline request doesn't seem to work; it should
certainly NOT emit a symbol to the object file in cases where the function is
never called (and try to inline when it is).
There should only be a symbol in the object file in the case it failed to
inline, and only if it's actually called.

inline functions are useful for things like CTFE, where you want to use a
function at compile time, and may _or may not_ use it at runtime, and do not
want to eagerly emit it to the binary.

--
Jan 10