URL:
  <http://gna.org/bugs/?20447>

                 Summary: 'trade_routes_color' may be used uninitialized
                 Project: Freeciv
            Submitted by: cazfi
            Submitted on: Mon 21 Jan 2013 12:25:17 AM EET
                Category: client
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: Ready For Test
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 
         Discussion Lock: Any
        Operating System: None
         Planned Release: 2.3.4, 2.4.0, 2.5.0

    _______________________________________________________

Details:

With optimization level 3, gcc gives:

client/mapview_common.c: In function 'show_city_descriptions':
client/mapview_common.c:1655:22: error: 'trade_routes_color' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
client/mapview_common.c:1440:32: note: 'trade_routes_color' was declared here
client/mapview_common.c:1767:22: error: 'trade_routes_color' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
client/mapview_common.c:1701:32: note: 'trade_routes_color' was declared here


These seem like gcc is migdiagnosing the situation. In fact, it depends on
exact value assigned to trade_routes_color if warning is emitted or not, to
the extend that reassigning such an unacceptable value when there already is
prior assignment with acceptable value will cause the warning to be emitted.

Luckily, initializing variable when declared makes the warning to go away.
That's what attached patch does.


This is last compiler warning I had with optimization level 3 in S2_4.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 21 Jan 2013 12:25:17 AM EET  Name: TradeRoutesColorInit.patch  Size:
2kB   By: cazfi

<http://gna.org/bugs/download.php?file_id=16984>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?20447>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to