From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4691 invoked by alias); 29 Apr 2002 15:16:07 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 4642 invoked by uid 71); 29 Apr 2002 15:16:03 -0000 Resent-Date: 29 Apr 2002 15:16:03 -0000 Resent-Message-ID: <20020429151603.4641.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, stephen.hill@motorola.com Received:(qmail 4157 invoked by uid 61); 29 Apr 2002 15:15:10 -0000 Message-Id:<20020429151510.4156.qmail@sources.redhat.com> Date: Mon, 29 Apr 2002 08:16:00 -0000 From: stephen.hill@motorola.com Reply-To: stephen.hill@motorola.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/6507: auto type promotion of referee in reference member variable initialization X-SW-Source: 2002-04/txt/msg01596.txt.bz2 List-Id: >Number: 6507 >Category: c++ >Synopsis: auto type promotion of referee in reference member variable initialization >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Mon Apr 29 08:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: stephen.hill@motorola.com >Release: gcc 2.95.2 19991024 (release) >Organization: >Environment: Linux x86 (suse 7.0 default install) >Description: Note: I'm not sure if this really is a bug (or just a feature), but it strikes me that the code is doing something so different from a reasonable expectation that a closer examination of the reasoning might be desirable. When initializing a reference member variable of a class, it appears that gcc attempts do do a type promotion of the referee into the reference class, then references the promoted variable. In the attached code, note the difference between reference and referee addresses.If the constructor (lines 19-22) is replaced by a constructor which does not take an argument of the reference type (lines 24-27) an error is generated. This makes me believe that automatic type promotion is involved. Note that if b (line 38) is declared as const explicit Foo &b; rather than const Foo &b then no problem results. Thanks, steve >How-To-Repeat: compile attached file (gcc -o bug_test bug_test.cc) run (./bug_test) >Fix: Assume that member references to member variables are explicit or warn? >Release-Note: >Audit-Trail: >Unformatted: