From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 20B0B3858412 for ; Mon, 24 Oct 2022 15:42:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 20B0B3858412 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666626169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XZvQJAiTyYyBZbA+m5hZF5jkEampqVAk0gMbVdP4Lrk=; b=NM+L2EpaA7h7sLAzsiwVzMhZpOl7d3EExmiDauLuPs2MMXDfu/jlu5tA1ExOIiE8T1gWcx i7vJ+Tg6tPzVTBaNiRt5J/OWS7itc8W+2jNQ7tnSfk0n58YmFKvLdtMxUZxwKOVYAEFXU+ XtsP4XJtjjRt3YmpDWBtUnXEP3Pgrzk= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-301-Cu-rH_35MpW3bAM-WOezAw-1; Mon, 24 Oct 2022 11:42:48 -0400 X-MC-Unique: Cu-rH_35MpW3bAM-WOezAw-1 Received: by mail-qt1-f198.google.com with SMTP id a19-20020a05622a02d300b0039a3711179dso7276796qtx.12 for ; Mon, 24 Oct 2022 08:42:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XZvQJAiTyYyBZbA+m5hZF5jkEampqVAk0gMbVdP4Lrk=; b=owi+opWfc8BvSCKlAou9i2xvyyIa70S2Qqzw0INlu7k+XM81MkLry8A0Xtg10zUwyI GD+jojJYfmK6RAyuUUnCzoUXv8DE26Pf3dxylmkXobKeknAzA7nwSyG8ddPFvkRWCnsh br8b9yDL3UOZZYUn2SrQT1PV5Zm7oGWHHbaiZl6jBxpke9VRA0DtjQ44DzbEgqvxQfTF OREVqgZNwKZUU/zU3/aGp+DY32G87hRcO8v3toDifvyXLomStoNOFU5OgEJfHmkSDcS7 wSjn4VjG08OLxuLhYAs8VPZCY8ThGsqF3Vnrx7x9OeuhXvCa/Bzr5iIMODhxj4xwjtxo mo8Q== X-Gm-Message-State: ACrzQf19C/M4Yl54QVaL1slSuiLWjqNKxCA/407KryyziQFA1qkIzOXM eZZufSkQR8BwlzQ2DJKfpBzvSxfXGAAvTxsfhSkz+gTbS94nKD3Gx30taIFHl/JybFhMBCWmt0b pS08LUjIDc0DD4mMoFOoJQw== X-Received: by 2002:a05:620a:4005:b0:6ee:d836:9ed4 with SMTP id h5-20020a05620a400500b006eed8369ed4mr23377223qko.352.1666626167891; Mon, 24 Oct 2022 08:42:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pokXIVH/8hXZWOWq2dTPuG8dUrLYq3lwfosVDmQAKHhUyxguz9D1idm2xsIJ0Z1hZ7epE2A== X-Received: by 2002:a05:620a:4005:b0:6ee:d836:9ed4 with SMTP id h5-20020a05620a400500b006eed8369ed4mr23377209qko.352.1666626167652; Mon, 24 Oct 2022 08:42:47 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id y19-20020a05620a25d300b006ec62032d3dsm184354qko.30.2022.10.24.08.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 08:42:47 -0700 (PDT) From: Andrew Burgess To: Mike Frysinger Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 4/5] sim/erc32: avoid dereferencing type-punned pointer warnings In-Reply-To: References: Date: Mon, 24 Oct 2022 16:42:45 +0100 Message-ID: <87tu3t8byi.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Mike Frysinger writes: > On 12 Oct 2022 13:38, Andrew Burgess via Gdb-patches wrote: >> When building the erc32 simulator I get a few warnings like this: >> >> /tmp/build/sim/../../src/sim/erc32/exec.c:1377:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] >> 1377 | sregs->fs[rd] = *((float32 *) & ddata[0]); >> | ~^~~~~~~~~~~~~~~~~~~~~~~ >> >> The type of '& ddata[0]' will be 'uint32_t *', which is what triggers >> the warning. >> >> This commit uses an intermediate pointer of type 'char *' when >> performing the type-punning, which is well-defined behaviour, and will >> silence the above warning. > > this is kind of a poor fix. if we can't arrange for the pointers to be > the right type, at least a memcpy would be better. This was already discussed in this thread: https://sourceware.org/pipermail/gdb-patches/2022-October/192604.html The version that got pushed: https://sourceware.org/pipermail/gdb-patches/2022-October/192647.html does make use of memcpy. Thanks, Andrew