From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23308 invoked by alias); 16 Jan 2019 12:28:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23279 invoked by uid 89); 16 Jan 2019 12:28:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Jan 2019 12:28:31 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50CD72D80F; Wed, 16 Jan 2019 12:28:30 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E37C4106F94F; Wed, 16 Jan 2019 12:28:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x0GCSRTZ016827; Wed, 16 Jan 2019 13:28:28 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x0GCSQx3016826; Wed, 16 Jan 2019 13:28:26 +0100 Date: Wed, 16 Jan 2019 12:28:00 -0000 From: Jakub Jelinek To: "H.J. Lu" Cc: GCC Patches , Jason Merrill Subject: Re: [PATCH] c-family: Update unaligned adress of packed member check Message-ID: <20190116122826.GS30353@tucnak> Reply-To: Jakub Jelinek References: <20190113124838.29506-1-hjl.tools@gmail.com> <20190113132020.GY30353@tucnak> <20190114142214.GE30353@tucnak> <20190116113006.GQ30353@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00905.txt.bz2 On Wed, Jan 16, 2019 at 04:11:44AM -0800, H.J. Lu wrote: > > Why? What is so special about C and (implicit?) casts where the rhs isn't > > ADDR_EXPR? Aren't all casts (explicit or implicit) from one pointer type > > to another pointer and satisfy the rules something that should be warned > > -Wincompatible-pointer-types is C only. In C++, incompatible pointer types > aren't allowed at all. How so? You can certainly: struct B { int i; }; struct C { struct B b; } __attribute__ ((packed)); extern struct C *p; long* g8 (void) { return (long *)p; } and similarly for C. So, why is explicit cast something that shouldn't be warned about in this case and implicit cast should get a warning, especially when it already does get one (and one even enabled by default, -Wincompatible-pointer-types)? Either such casts are problematic and then it should treat explicit and implicit casts the same, or they aren't, and then -Wincompatible-pointer-types is all you need. Jakub