The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    • RT @WietsedeBoer2: Als (grond)water zo schaars is, waarom krijgt dit bedrijf dan een vergunning voor oppompen van 500.000 m3 water? Ergens… 2 hours ago
    • RT @bitsoffreedom: Stel vragen! En belangrijker, dit is gewoon iets voor het kabinet om netjes te regelen, dat is beter voor de ondernemers… 2 hours ago
    • RT @Crash2411: This tweet was postmarked last month 2 hours ago
    • RT @Afelia: Mailadresse. Die politische Debatte über digitale Bildung hängt solide 15 Jahre hinterher. 2 hours ago
    • RT @TerliWetter: “Nahezu sein gesamter Maisbestand hat sich in Popcorn verwandelt. Schuld ist wohl die aktuelle Hitzewelle, die deutschland… 3 hours ago
  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,052 other followers

Bogus W1036 ? 

Posted by jpluimers on 2020/07/30

Reminder to self for checking if this still fails:

[WayBack] Bogus W1036 ? Documentation: … “If you do not explicitly initialize a global variab… – Stefan Glienke – Google+

Documentation: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Variables_(Delphi)

“If you do not explicitly initialize a global variable, the compiler initializes it to 0.”

{$APPTYPE CONSOLE}

var
  i: Integer;
begin
  Writeln(i);
end.

Error:

[DCC Warning] Project1.dpr(6): W1036 Variable 'i' might not have been initialized

–jeroen

2 Responses to “Bogus W1036 ? ”

  1. abouchez said

    Yes. All global variables are allocated at once when the exe is loaded, as a whole private in-memory section, and filled by the Operating System executable loader with zeros.

    This warning is indeed paranoid, and only affect the dpr (not the units).
    In fact, this is a compiler optimization. This variable i is not identified as a global variable, but a local variable – typically it could be used in a loop.
    Usually, I never put any loop and such in the main begin…end block of the dpr. I try to always use an explicit sub-function.

    So this is not a bug, this is a feature, from the compiler point of view.

    • Stefan Glienke said

      I cannot count how often I had weird issues with all kinds of things just because I thought that just quickly testing something in the dpr main was a good idea.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: