@forceInline can't inline when source code is available

Iain Buclaw via D.gnu d.gnu at puremagic.com
Wed May 27 23:32:42 PDT 2015


On 28 May 2015 04:15, "Mike via D.gnu" <d.gnu at puremagic.com> wrote:
>
> Consider this code
>
> testInline.d
> ************
> module testInline;
>
> import gcc.attribute;
>
> public enum inline = gcc.attribute.attribute("forceinline");
>
> @inline int add(int a, int b)
> {
>     return a + b;
> }
>
> test.d
> ******
> import std.stdio;
>
> import testInline;
>
> void main()
> {
>     writeln(add(1, 2));
> }
>
> Compiler Output
> ***************
> gdc test.d
> test.d: In function 'D main':
> testInline.d:7:13: error: inlining failed in call to always_inline 'add':
function body not available
>  @inline int add(int a, int b)
>              ^
> test.d:8:5: error: called from here
>      writeln(add(1, 2));
>      ^
>
>
> Shouldn't it be able to inline the "add" function since the source code
is there in the testInline.d file?  Should I file a bug?
>

It's well known that cross-module inlining doesn't work for separate
compilation.  Only option is to compile all sources in one go.

Isin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20150528/9c46fc55/attachment.html>


More information about the D.gnu mailing list