[SOVLED] weird compiler behaviour (bug?) lazarus / 62-General ---------------------------------------------------------------------- MMarie · 2025-05-06 01:00 Hi, I just encountered some weird compiler behaviour while working on my test project for my UEFI bindings and wanted to share it here. It feels like a compiler bug but I don't want to jump the horse so quickly  The quick break down: I have a procedure for converting a UInt64 to a hexadecimal string and printing it via UEFI. The weird thing is that depending on the placement of another call to my Print function, only one character or all characters from my string are shown. Snippet with correct behaviour: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure PrintHex(_int: UInt64);const        MAX_DIGITS = 32;        DIGITS: array of WideChar = ('0','1','2','3','4','5','6','7','8','9','A','B','C',                                                               'D','E','F');var      wix, ix: Integer;        b: UInt8;        c: array [0..1] of WideChar;        _str: array [0..MAX_DIGITS] of WideChar;begin        c[0] := '$';        c[1] := WideChar($0000);         wix := High(_str);        _str[wix] := WideChar($0000);        Dec(wix);       Print(@c[0]);         repeat                _str[wix] := DIGITS[_int mod 16];                _int := _int div 16;              Inc(ix);                Dec(wix);        until (_int = 0) or (ix >= MAX_DIGITS);         Print(PWideChar(_str) + wix);end;  Snippet with incorrect behaviour: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure PrintHex(_int: UInt64);const        MAX_DIGITS = 32;        DIGITS: array of WideChar = ('0','1','2','3','4','5','6','7','8','9','A','B','C',                                                               'D','E','F');var      wix, ix: Integer;        b: UInt8;        c: array [0..1] of WideChar;        _str: array [0..MAX_DIGITS] of WideChar;begin        c[0] := '$';        c[1] := WideChar($0000);         Print(@c[0]);       wix := High(_str);        _str[wix] := WideChar($0000);        Dec(wix);         repeat                _str[wix] := DIGITS[_int mod 16];                _int := _int div 16;                Inc(ix);              Dec(wix);        until (_int = 0) or (ix >= MAX_DIGITS);       Print(PWideChar(_str) + wix);end;  (If you want to see it in full context, the code is available here) EDIT: please also go easy on me, especially in regards to my code, i am very sleep deprived ---------------------------------------------------------------------- Fibonacci · 2025-05-06 01:38 Thanks. I dont know the answer to your problem, but thanks to you I just found another Internal Error (2013032603). I collect them. #41249 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  c: char;  s: string; begin  Str(c, s); // Error: Internal error 2013032603end. ---------------------------------------------------------------------- Fibonacci · 2025-05-06 01:58 I dont see the "ix" initialized, I guess it may be unpredictable ---------------------------------------------------------------------- MMarie · 2025-05-06 08:26 Quote from: Fibonacci on May 06, 2025, 03:58:34 amI dont see the "ix" initialized, I guess it may be unpredictable Oh yeah, you are completly correct. I overlooked that completly. A bit of a look into it shows that "ix" just happend to equal MAX_DIGITS - 1 when I forgot to initialise it. Although now I'm wondering what I screwed up in my Makefile that I'm not getting any compiler warnings