www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14074] New: non-separate compilation fails, but separate

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

          Issue ID: 14074
           Summary: non-separate compilation fails, but separate
                    compilation works
           Product: D
           Version: D2
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: ketmar ketmar.no-ip.org

steps to reproduce:

git clone https://github.com/MrSmith33/cbor-d.git
cd cbor-d
git reset --hard 7fc1a49145b632674b071a525ca22c6010f451b7
cat >z00.d
import std.stdio;
import cbor;

struct Inner {
  int[] array;
  string someText;
}

struct Test {
  ubyte b;
  short s;
  uint i;
  long l;
  float f;
  double d;
  ubyte[] arr;
  string str;
  Inner inner;

  void fun(){} // not encoded
  void* pointer; // not encoded
  int* numPointer; // not encoded
}


void main () {
  ubyte[1024] buffer;
  size_t encodedSize;

  Test test = Test(42, -120, 111111, -123456789, 0.1234, -0.987654,
    cast(ubyte[])[1,2,3,4,5,6,7,8], "It is a test string",
    Inner([1,2,3,4,5], "Test of inner struct"));

  encodedSize = encodeCborArray(buffer[], test);

  // ubyte[] and string types are slices of input ubyte[].
  Test result = decodeCborSingle!Test(buffer[0..encodedSize]);

  // decodeCborSingleDup can be used to auto-dup those types.

  assert(test == result);

  {
    auto fo = File("z.bin", "w");
    fo.rawWrite(buffer[0..encodedSize]);
  }
}
^D
dmd z00.d cbor.d

z00.o: In function `cbor.putChecked!(ubyte[], ubyte).putChecked(ref ubyte[],
const(ubyte))':
cbor.d:(.text._D4cbor21__T10putCheckedTAhThZ10putCheckedFNaNbNiNfKAhxhZv+0xa):
undefined reference to `std.range.primitives.put!(ubyte[],
const(ubyte)).put(ref ubyte[], const(ubyte))'
z00.o: In function `cbor.putChecked!(ubyte[], ubyte[]).putChecked(ref ubyte[],
const(ubyte[]))':
cbor.d:(.text._D4cbor22__T10putCheckedTAhTAhZ10putCheckedFNaNbNiNfKAhxAhZv+0xd):
undefined reference to `std.range.primitives.put!(ubyte[],
const(ubyte)[]).put(ref ubyte[], const(ubyte)[])'
z00.o: In function `cbor.putChecked!(ubyte[], ubyte[]).putChecked(ref ubyte[],
ref const(ubyte[]))':
cbor.d:(.text._D4cbor22__T10putCheckedTAhTAhZ10putCheckedFNaNbNiNfKAhKxAhZv+0xf):
undefined reference to `std.range.primitives.put!(ubyte[],
const(ubyte)[]).put(ref ubyte[], const(ubyte)[])'
collect2: error: ld returned 1 exit status

yet this works ok:
dmd -c cbor.d
dmd z00.d cbor.o


p.s. gdc with 2.066.1 backend is working ok for both cases.

--
Jan 28 2015