From patchwork Wed Nov 24 09:39:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joern Rennecke X-Patchwork-Id: 72824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id ED596B70A7 for ; Wed, 24 Nov 2010 20:39:52 +1100 (EST) Received: (qmail 5507 invoked by alias); 24 Nov 2010 09:39:49 -0000 Received: (qmail 5435 invoked by uid 22791); 24 Nov 2010 09:39:47 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from c60.cesmail.net (HELO c60.cesmail.net) (216.154.195.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 24 Nov 2010 09:39:43 +0000 Received: from unknown (HELO epsilon2) ([192.168.1.60]) by c60.cesmail.net with ESMTP; 24 Nov 2010 04:39:41 -0500 Received: from 89.241.145.88 ([89.241.145.88]) by webmail.spamcop.net (Horde MIME library) with HTTP; Wed, 24 Nov 2010 04:39:40 -0500 Message-ID: <20101124043940.y5q6ojjoaoooo44w-nzlynne@webmail.spamcop.net> Date: Wed, 24 Nov 2010 04:39:40 -0500 From: Joern Rennecke To: gcc-patches@gcc.gnu.org Subject: RFA: Fix PR c++/46634 MIME-Version: 1.0 User-Agent: Internet Messaging Program (IMP) H3 (4.1.4) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Bootstrapped and regression tested on i686-pc-linux.gnu. 2010-11-22 Joern Rennecke PR c++/46634 * typeck2.c (digest_init_r): Use TYPE_PRECISION (char_type_node) as the size of char. Index: gcc/gcc/cp/typeck2.c =================================================================== --- gcc/gcc/cp/typeck2.c (revision 167107) +++ gcc/gcc/cp/typeck2.c (working copy) @@ -881,7 +881,7 @@ digest_init_r (tree type, tree init, boo { tree char_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init))); - if (TYPE_PRECISION (typ1) == BITS_PER_UNIT) + if (TYPE_PRECISION (typ1) == TYPE_PRECISION (char_type_node)) { if (char_type != char_type_node) { @@ -907,7 +907,9 @@ digest_init_r (tree type, tree init, boo if (TYPE_DOMAIN (type) != 0 && TREE_CONSTANT (TYPE_SIZE (type))) { int size = TREE_INT_CST_LOW (TYPE_SIZE (type)); - size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT; + unsigned char_size = TYPE_PRECISION (char_type_node); + + size = (size + char_size - 1) / char_size; /* In C it is ok to subtract 1 from the length of the string because it's ok to ignore the terminating null char that is counted in the length of the constant, but in C++ this would