public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/94455] New: no [] operator overload for type
@ 2020-04-02 12:57 jakub at gcc dot gnu.org
  2020-04-02 14:32 ` [Bug d/94455] " ibuclaw at gdcproject dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-02 12:57 UTC (permalink / raw)
  To: gcc-bugs

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;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-19 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 12:57 [Bug d/94455] New: no [] operator overload for type jakub at gcc dot gnu.org
2020-04-02 14:32 ` [Bug d/94455] " ibuclaw at gdcproject dot org
2020-04-19 18:11 ` cvs-commit at gcc dot gnu.org
2020-04-19 18:14 ` ibuclaw at gdcproject dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).