From 4a96db860c95ed6ea8a03cb24c54ebfb9325ada8 Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 16:47:08 +0330 Subject: globals: an integer constant initializing a float or f32 global converts to float (float g = 2; is 2.0) --- src/compiler/decl.zc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3