From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5050 invoked by alias); 6 Nov 2008 15:16:58 -0000 Received: (qmail 28603 invoked by uid 48); 6 Nov 2008 15:15:32 -0000 Date: Thu, 06 Nov 2008 15:16:00 -0000 Message-ID: <20081106151532.28602.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/38007] [4.2/4.3/4.4 Regression] g++ instantiate same operator twice due to bitfield in -O0 mode, causing symbol already defined assembler error In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-11/txt/msg00489.txt.bz2 ------- Comment #3 from jakub at gcc dot gnu dot org 2008-11-06 15:15 ------- And for: struct A { template __attribute__((noinline)) operator T () { return (T) 0; } }; struct B { unsigned int b : 8; }; int main () { A u; unsigned int v = u; B w; w.b = u; } we instantiate both A::operator unsigned int() A::operator unsigned char() Shouldn't it use unsigned int conversion in both cases as well, or is it allowed (or required) to use the lowered type? I see 3.4 through 4.4 all use unsigned char, if RHS' type isn't MAYBE_CLASS_TYPE_P, then I understand it, but for class RHS it is an important difference. I believe the place which needs to be revisited is cp_build_modify_expr, if is_bitfield_expr_with_lowered_type use the type returned by that in convert_for_assignment. But I'm e.g. confused by: /* If storing into a structure or union member, it has probably been given type `int'. Compute the type that would go with the actual amount of storage the member occupies. */ if (TREE_CODE (lhs) == COMPONENT_REF && (TREE_CODE (lhstype) == INTEGER_TYPE || TREE_CODE (lhstype) == REAL_TYPE || TREE_CODE (lhstype) == ENUMERAL_TYPE)) { lhstype = TREE_TYPE (get_unwidened (lhs, 0)); ... } That seems like a remnant from the past, as get_unwidened for COMPONENT_REF does nothing but return the passed object. See http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01621.html -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mmitchel at gcc dot gnu dot | |org, dodji at gcc dot gnu | |dot org, jason at gcc dot | |gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38007