Red Hat Bugzilla – Bug 433580
g++ does not issue accessibility error
Last modified: 2013-11-26 13:14:11 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.5.20404)
Description of problem:
This shows a Gnu compiler bug. The Intel Linux compiler and the latest
Microsoft (MSVC++ 2008) compiler give an error but Gnu does not.
Stroustrup's C++ Programming Language 3rd edition, section 15.3.2 says:
If B is a protected base ... Only friends and members of D and friends
and members of class derived from D can convert D* to a B*.
In this example Base is a protected base and Base is not derived
from Derived so this should get an error.
void baseFunction() ;
// g++ gives an error if Base is private -- but not protected
class Derived : protected Base // no error with g++
Derived* dp = 0;
Base* bp = 0;
bp = dp;
Version-Release number of selected component (if applicable):
gcc version 4.1.1 20070105
Steps to Reproduce:
1. g++ bug.cpp
I did not see a compilation error.
I should have seen an error similar to this one from the Intel compiler:
tr78887a.cpp(26): error #312: conversion to inaccessible base class "Base" is not allowed
bp = dp;
This Bugzilla has been reviewed by Red Hat and is not planned on being
addressed in Red Hat Enterprise Linux 5, and therefore will be closed.
If this bug is critical to production systems, please contact your Red
Hat support representative and provide sufficient business
justification. Issue is already fixed in RHEL-6/7 as well as in the Developer Tool Set compilers which are available for RHEL-5.