Opened 5 months ago

Closed 3 months ago

#11538 closed defect (fixed)

BASE: ODR violations (-flto)

Reported by: lacc97 Owned by: sev-
Priority: normal Component: --Unset--
Keywords: Cc:
Game:

Description

Compilation of 2.1.2 with -flto on Gentoo Linux (GCC 10.1) generates ODR warnings.

  • engines/illusions
    ./engines/illusions/bbdou/bbdou_credits.h:35:8: warning: type ‘struct CreditsItem’ violates the C++ One Definition Rule [-Wodr]
       35 | struct CreditsItem {
          |        ^
    ./engines/illusions/duckman/duckman_credits.h:32:8: note: a different type is defined in another translation unit
       32 | struct CreditsItem {
          |        ^
    ./engines/illusions/bbdou/bbdou_credits.h:36:7: note: the first difference of corresponding definitions is field ‘isUsed’
       36 |  bool isUsed;
          |       ^
    ./engines/illusions/duckman/duckman_credits.h:33:9: note: a field with different name is defined in another translation unit
       33 |  uint32 objectId;
          |
    
  • audio
    audio/fmopl.cpp:42: warning: ‘create’ violates the C++ One Definition Rule [-Wodr]
       42 |  OPL *create(Config::OplType type);
          | 
    audio/alsa_opl.cpp:344: note: return value type mismatch
      344 | OPL *create(Config::OplType type) {
          | 
    audio/alsa_opl.cpp:47: note: type name ‘OPL::ALSA::OPL’ should match type name ‘OPL::OPL’
       47 | class OPL : public ::OPL::RealOPL {
          | 
    ./engines/scumm/players/player_ad.h:32:7: note: the incompatible type is defined here
       32 | class OPL;
          |       ^
    audio/alsa_opl.cpp:344: note: ‘create’ was previously declared here
      344 | OPL *create(Config::OplType type) {
          | 
    audio/alsa_opl.cpp:344: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
    

As far as I can tell this doesn't result in runtime bugs but it is still undefined behaviour and may cause problems in the future.

Change History (2)

comment:1 by raziel-, 4 months ago

Summary: ODR violationsBASE: ODR violations (-flto)

comment:2 by sev-, 3 months ago

Owner: set to sev-
Resolution: fixed
Status: newclosed

The first one was fixed, the second one is much trickier and is basically by design.

Thanks for reporting.

Note: See TracTickets for help on using tickets.