public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/97843] New: Bad code gen when concatenating to array
@ 2020-11-16  1:11 alex at sunopti dot com
  2020-11-16 11:31 ` [Bug d/97843] " ibuclaw at gdcproject dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: alex at sunopti dot com @ 2020-11-16  1:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97843
           Summary: Bad code gen when concatenating to array
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: alex at sunopti dot com
  Target Milestone: ---

This code:

import std.stdio;

ubyte sum(ubyte[] bytes)
{
        ubyte result;
        foreach(x;bytes)
                result += x;
        return result;
}

int main()
{
        ubyte[] bytes = [0,1];
        bytes ~= bytes.sum;
        writefln("sum = %s",bytes[$-1]);
        return 0;
}

Expected output :
sum = 1 as confirmed at https://dlang.org/ your code here
Actual output :
sum = <random number>

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

end of thread, other threads:[~2020-11-18 10:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16  1:11 [Bug d/97843] New: Bad code gen when concatenating to array alex at sunopti dot com
2020-11-16 11:31 ` [Bug d/97843] " ibuclaw at gdcproject dot org
2020-11-16 12:16 ` alex at sunopti dot com
2020-11-16 15:34 ` ibuclaw at gdcproject dot org
2020-11-16 15:35 ` ibuclaw at gdcproject dot org
2020-11-16 16:17 ` ibuclaw at gdcproject dot org
2020-11-16 20:56 ` alex at sunopti dot com
2020-11-18 10:32 ` cvs-commit at gcc dot gnu.org
2020-11-18 10:37 ` ibuclaw at gdcproject dot org
2020-11-18 10:38 ` 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).