Bug 10305 – Make array operations output type the same as the input one for fixed sized arrays

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-08T14:51:41Z
Last change time
2024-12-13T18:08:00Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18606 →

Comments

Comment #0 by bearophile_hugs — 2013-06-08T14:51:41Z
This issue is borderline between an enhancement request and a bug report. void main() { double[3] a; pragma(msg, typeof(a[] ^^ 2)); float[3] b; pragma(msg, typeof(b[] ^^ 2)); } Output: double[] float[] But I think the output should be: double[3] float[3] Keeping the static information of the length of the array is useful for small arrays for successive better optimizations.
Comment #1 by yebblies — 2013-11-21T04:24:44Z
a[] has type double[], s this is already doing what you said.
Comment #2 by bearophile_hugs — 2013-11-21T07:00:07Z
(In reply to comment #1) > a[] has type double[], s this is already doing what you said. Then this ER asks for something un-standard and special, even if it needs some hack in the compiler: keeping the compile-time knowledge of the array length is very important to optimize well enough vector operations on fixed sized arrays. This is a important enhancement request.
Comment #3 by robert.schadek — 2024-12-13T18:08:00Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18606 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB