@forceInline can't inline when source code is available

Mike via D.gnu d.gnu at puremagic.com
Wed May 27 19:12:10 PDT 2015

Consider this code

module testInline;

import gcc.attribute;

public enum inline = gcc.attribute.attribute("forceinline");

@inline int add(int a, int b)
     return a + b;

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 


More information about the D.gnu mailing list