Bug 19482 – attributes incorrectly applied to static foreach local variables

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-12-12T23:10:26Z
Last change time
2021-11-02T14:28:38Z
Keywords
C++, industry, pull
Assigned to
No Owner
Creator
Manu

Comments

Comment #0 by turkeyman — 2018-12-12T23:10:26Z
extern(C++) class foo { static foreach (i; 0 .. 100) { } } > Error : Internal Compiler error : type `int[]` can not be mapped to C++ Build using latest DMD for Win64.
Comment #1 by iamthewilsonator — 2018-12-12T23:59:33Z
Hmm, works fine on Posix. -vcg-ast gives --- import object; void main() { return 0; } extern (C++) class foo { static foreach (i; tuple(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99)) { {} } } RTInfo!(foo) { enum typeof(null) RTInfo = null; } --- No int[] in sight. What does -vcg-as gives on Win64?
Comment #2 by turkeyman — 2018-12-13T01:30:45Z
It doesn't give anything, because the ICE... ;)
Comment #3 by iamthewilsonator — 2018-12-13T03:34:58Z
> It doesn't give anything, because the ICE... ;) Haha. And if you comment out the ICE?
Comment #4 by timon.gehr — 2018-12-13T04:04:29Z
The issue is that type qualifiers in the context are applied to `static foreach`-local variables. This behavior is unintended and changing it will fix the ICE. E.g.: immutable static foreach(i;0..1) pragma(msg, typeof(i)); will print `immutable(int)`, but it should print `int`.
Comment #5 by turkeyman — 2018-12-13T07:46:49Z
Oh wow. Yeah, that's pretty broken :)
Comment #6 by moonlightsentinel — 2021-04-04T19:18:42Z
The initial test case compiles fine with current master
Comment #7 by timon.gehr — 2021-04-05T06:56:07Z
(In reply to moonlightsentinel from comment #6) > The initial test case compiles fine with current master Can confirm (using wine on linux). However, it seems the underlying issue remains unfixed, changing title.
Comment #8 by dlang-bot — 2021-11-01T05:48:39Z
@BorisCarvajal created dlang/dmd pull request #13253 "Fix Issue 19482 - attributes incorrectly applied to static foreach local variables" fixing this issue: - Fix Issue 19482 - attributes incorrectly applied to static foreach local variables https://github.com/dlang/dmd/pull/13253
Comment #9 by dlang-bot — 2021-11-02T14:28:38Z
dlang/dmd pull request #13253 "Fix Issue 19482 - attributes incorrectly applied to static foreach local variables" was merged into master: - 0409dfc969e8e7794e6a2b6971b30f9e26b15cae by Boris Carvajal: Fix Issue 19482 - attributes incorrectly applied to static foreach local variables https://github.com/dlang/dmd/pull/13253