This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81674] New: gcc cannot detect missing initialisers for fields in constructors


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

            Bug ID: 81674
           Summary: gcc cannot detect missing initialisers for fields in
                    constructors
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Given the following C++ source code:

struct S
{
        int a, b, c;

        S() : a( 0)
        {
                b = 1;
        };
};

then I cannot get gcc to detect the missing initialiser for field c.

$ ~/gcc/results/bin/gcc -c -O2 -Wall -Wextra aug2a.cc
$

Here is static analyser cppcheck finding the problem:

$ ~/cppcheck/trunk/cppcheck --enable=all aug2a.cc
[aug2a.cc:8]: (warning) Member variable 'S::c' is not initialized in the
constructor.
$

cppcheck can find 55 examples of this problem in the gcc source code alone,
so it would appear to be of some value to gcc, to say nothing of customers
of gcc.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]