Bug 433580 - g++ does not issue accessibility error
g++ does not issue accessibility error
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gcc (Show other bugs)
i686 Linux
low Severity medium
: rc
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2008-02-19 23:50 EST by Judy Ward
Modified: 2013-11-26 13:14 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-11-26 13:14:11 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Judy Ward 2008-02-19 23:50:32 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.

struct Base
    void baseFunction() ;

// g++ gives an error if Base is private -- but not protected
class Derived : protected Base // no error with g++

void Base::baseFunction()
  Derived* dp = 0;
  Base* bp = 0;
  bp = dp;

Version-Release number of selected component (if applicable):
gcc version 4.1.1 20070105 

How reproducible:

Steps to Reproduce:
1. g++ bug.cpp

Actual Results:

I did not see a compilation error.

Expected Results:

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;

Additional info:
Comment 2 Jeff Law 2013-11-26 13:14:11 EST
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.

Note You need to log in before you can comment on or make changes to this bug.