Skip to content

Commit 838e7aa

Browse files
chqrliebvdberg
authored andcommitted
Compiler: prevent warnings in C compilation for older gcc
* prevent warning on signed/unsigned comparison for `u32 < u8` * prevent warning on unintialized `k` after switch.
1 parent bcf5985 commit 838e7aa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

generator/c2refs.c2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ fn void Lengths.fillDest(const Lengths* l, Dest* result, u32 offset, u32 start,
342342
u32 last = start + count;
343343
u32 line = 1;
344344
for (u32 i = start; i < last; i++) {
345-
u8 len = l.lengths[i];
346-
if (offset < len) break; // <=?
345+
u32 len = l.lengths[i];
346+
if (offset < len) break;
347347
offset -= len;
348348
line++;
349349
}

ir/context.c2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public fn Ref Context.addLoadInstr(Context* c, Type t, Ref src) {
434434

435435
Ref out.init(RefKind.Temp, c.b.tmp_info.instructions.getCount());
436436

437-
InstrKind k;
437+
InstrKind k = None; // prevent C warning
438438
switch (t) {
439439
case None:
440440
assert(0);

0 commit comments

Comments
 (0)