array concatenation is not working

Anonymous avatarAnonymous created an issue

Tested with gdc version gcc version 4.4.5 and D version 2.

import std.stdio;
void main(){
    byte[] arr, tmp;
    arr = [0, 1, 3];
    tmp = [2];
    arr = arr[0..2] ~ tmp ~ arr[2..$];
gdc test.d -o test_gdc && ./test_gdc
dmd test.d -oftest_gdc && ./test_gdc
[1, 2, 3, 4]

Comments (7)

  1. Anonymous

    I'm using amd64 and the change solved the reported problem: gdc test.d -o test_gdc && ./test_gdc [0 1 2 3] dmd test.d -oftest_gdc && ./test_gdc [0, 1, 2, 3] Thanks. But the original not-too-simplified problem still remains:

    import std.encoding;
    import std.stdio;
    void main(){
        Latin1Char[] arr     = [0x22, 0x31, 0x31, 0x22];
        Latin1Char[] padding = [0x30, 0x30];
        arr = arr[0] ~ padding ~ arr[1..$];
    gdc test.d
    In file included from <builtin>:2:
    test.d: In function 'main':
    test.d:6: internal compiler error: in toDArray, at d/
  2. Iain Buclaw

    Seems to occur when the array is a typedef...

    Minimal testcase that is reproducible on D1 too.

    typedef ubyte MyChar;
    void main(){
       MyChar[] arr = [0x22];
       arr = arr[0] ~ arr[0 .. $];
  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.