https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94455

            Bug ID: 94455
           Summary: no [] operator overload for type
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

The following testcase is rejected by gdc (trunk, or 9.x), while accepted by
dmd 2.089 or ldc 1.18.0 or later (tried on d.godbolt.org).  Though, admittedly
dmd 2.082 or ldc 1.17.0 and earlier also reject it.
import std.stdio;
import std.array;
import std.conv;

int main()
{

  auto w = appender!string;
  // pre-allocate space for at least 10 elements (this avoids costly
reallocations)
  w.reserve(10);
  assert(w.capacity >= 10);

  w.put('a'); // single elements
  w.put("bc"); // multiple elements

  // use the append syntax
  w ~= 'd';
  w ~= "ef";

  writeln(w[]); // "abcdef"

  return 0;
}

Reply via email to