[Bug c++/71482] New: Add -Wglobal-constructors warning option

egall at gwmail dot gwu.edu gcc-bugzilla@gcc.gnu.org
Thu Jun 9 20:14:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71482

            Bug ID: 71482
           Summary: Add -Wglobal-constructors warning option
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egall at gwmail dot gwu.edu
  Target Milestone: ---

Apple's gcc 4.2 has a warning flag called -Wglobal-constructors that they
describe in their invoke.texi like this:

    @c APPLE LOCAL begin Wglobal-constructors 6324584
    @item -Wglobal-constructors
    @opindex Wglobal-constructors
    Warn about namespace scope data that requires construction or
    destruction, or functions that use the constructor attribute or the
    destructor attribute.  Additionally warn if the Objective-C GNU
    runtime is used to initialize various metadata.
    @c APPLE LOCAL end Wglobal-constructors 6324584

In their c.opt it says:

    ; APPLE LOCAL begin Wglobal-constructors 6324584
    Wglobal-constructors
    C ObjC C++ ObjC++ Var(warn_global_constructors)
    Warn when global (namespace scope) objects require runtime
    construction or destruction or when functions that use attribute
    constructor or destructor are used.  This is useful to help maintain
    fast program startup and end times.
    ; APPLE LOCAL end Wglobal-constructors 6324584

Apparently this option has been carried forward to clang, as pointed out in bug
71456. It would be useful for FSF GCC to have this warning option, too.


More information about the Gcc-bugs mailing list