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++/44219] New: Public inheritance treated as private


I apologize if this is not a bug, or if it has been reported (I thoroughly
searched the bug database, but couldn't find anything related).
When class B publicly inherit class A, class A private members should be seen
as private in class B. However, they are not visible in class B (as if "public"
keyword was omitted). Here is the whole example:

class A {
  int x;
};

class B : public A {
  B()
  {
    x = 5;
  }

};


int main(int argc, char *argv[])
{
    return 0;
}

And here is the compiler output:
g++ -v -save-temps bug1.cpp

Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/specs
Target: x86_64-slackware-linux
Configured with: ../gcc-4.4.4/configure --prefix=/usr --libdir=/usr/lib64
--enable-shared --enable-bootstrap
--enable-languages=ada,c,c++,fortran,java,objc --enable-threads=posix
--enable-checking=release --with-system-zlib
--with-python-dir=/lib64/python2.6/site-packages --disable-libunwind-exceptions
--enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose
--disable-multilib --target=x86_64-slackware-linux
--build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 4.4.4 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
 /usr/libexec/gcc/x86_64-slackware-linux/4.4.4/cc1plus -E -quiet -v
-D_GNU_SOURCE bug1.cpp -mtune=generic -fpch-preprocess -o bug1.ii
ignoring duplicate directory "/usr/lib64/qt/include"
ignoring duplicate directory "/usr/lib/qt/include"
ignoring nonexistent directory
"/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../x86_64-slackware-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/qt/include
 /usr/lib/qt/include
 /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../include/c++/4.4.4

/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../include/c++/4.4.4/x86_64-slackware-linux

/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../include/c++/4.4.4/backward
 /usr/local/include
 /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/include
 /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
 /usr/libexec/gcc/x86_64-slackware-linux/4.4.4/cc1plus -fpreprocessed bug1.ii
-quiet -dumpbase bug1.cpp -mtune=generic -auxbase bug1 -version -o bug1.s
GNU C++ (GCC) version 4.4.4 (x86_64-slackware-linux)
        compiled by GNU C version 4.4.4, GMP version 5.0.1, MPFR version
2.4.2-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: df3503c115036a5e101a3ec035b30ab4
bug1.cpp: In constructor ?B::B()?:
bug1.cpp:5: error: ?int A::x? is private
bug1.cpp:12: error: within this context


-- 
           Summary: Public inheritance treated as private
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zeljkoj at tesla dot rcub dot bg dot ac dot rs
 GCC build triplet: x86_64-slackware-linux
  GCC host triplet: x86_64-slackware-linux
GCC target triplet: x86_64-slackware-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44219


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