Bug 13702 – One missed 'may cause GC allocation' error message

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-08T13:31:00Z
Last change time
2016-02-02T02:04:37Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-11-08T13:31:36Z
This program contains two similar functions, both contain two cases of GC allocations, but in 'bar' the D compiler misses one of them (it catches it later if you remove the first GC allocation inside 'bar'): int[] foo(bool b) @nogc { if (b) return [1]; return 1 ~ [2]; } int[] bar(bool b) @nogc { if (b) return [1]; auto aux = 1 ~ [2]; return aux; } void main() {} DMD 2.067alpha gives: test.d(3,16): Error: array literal in @nogc function foo may cause GC allocation test.d(4,16): Error: array literal in @nogc function foo may cause GC allocation test.d(9,20): Error: array literal in @nogc function bar may cause GC allocation
Comment #1 by k.hara.pg — 2015-09-01T04:50:36Z
Comment #2 by github-bugzilla — 2016-02-02T02:04:37Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/65b188f90809ca166161206fb33f1411a019b1a2 fix Issue 13702 - One missed 'may cause GC allocation' error message https://github.com/D-Programming-Language/dmd/commit/1a407903e9ec5b10d5990393b2c7f12a33b90e75 Merge pull request #5007 from 9rnsr/fix13702 Issue 13702 - One missed 'may cause GC allocation' error message