aboutsummaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:47:08 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:47:08 +0330
commit4a96db860c95ed6ea8a03cb24c54ebfb9325ada8 (patch)
tree9fa3a1fe8a667661cbc7efffa278702e44842604 /src/compiler
parentzc0umd: no recast uses a visible u/m/d as its tag (spec 1.6.3); spec: the fix... (diff)
globals: an integer constant initializing a float or f32 global converts to float (float g = 2; is 2.0)
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/decl.zc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/decl.zc b/src/compiler/decl.zc
index 371e8e8..e9500c4 100644
--- a/src/compiler/decl.zc
+++ b/src/compiler/decl.zc
@@ -484,7 +484,8 @@ int gdecl2(int t, int tg, int n) {
vv = tv; next(); if (t == tf32) vv = rt.zs2f(rt.zf2s(vv)); *(a + hdelta) = vv; // an f32 scalar is a rounded double
}
else {
- vv = cnorm(t, cexpr()); *(a + hdelta) = vv;
+ vv = cnorm(t, cexpr()); if (t && isfl(t)) { vv = vf_i2f(vv); if (t == tf32) vv = rt.zs2f(rt.zf2s(vv)); } // float g = 2; is 2.0
+ *(a + hdelta) = vv;
if (gok) { if (!gty) gty = tint; else if (gty != tint) gok = 0; }
}
} else if (gok) gok = 0; // no initializer: nothing says what it is