D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2151 - -release generates buggy array appending code
Summary: -release generates buggy array appending code
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-06-16 09:11 UTC by Artem Borisovskiy
Modified: 2015-06-09 01:21 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Artem Borisovskiy 2008-06-16 09:11:21 UTC
I have a loop like this:

i = 0;
...
while (i < s.length && s[i] != '"')
  {
    ...
    tmp ~= s[i];
    ++i;
  }
Usually it works great. When I use the -O flag, it sometimes crashes, but if I write it like this:
char c;
...
tmp ~= c = s[i];
... then it works great again. I don't see any reason for this strange behavior, except of optimizer's tricks.
Comment 1 Artem Borisovskiy 2008-06-17 07:34:20 UTC
Sorry for mistake. It's -release option's blame, but it's still a bug :)
Comment 2 Don 2008-06-30 08:02:41 UTC
Create a complete example showing the problem. Otherwise this will never get fixed.
Comment 3 Don 2009-09-20 12:32:16 UTC
This is probably just incorrect code, with memory corruption, and it's just "luck" that it works without -release. Marking as invalid since there's no test case, and there's an probable explanation which doesn't involve a compiler bug.