From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 993A33858423; Fri, 29 Oct 2021 20:09:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 993A33858423 Received: by mail-wr1-x42b.google.com with SMTP id u18so18307138wrg.5; Fri, 29 Oct 2021 13:09:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8RMZOg8jsdldkCGFklUoMBUvgdQySFZpasLcERSicf4=; b=N50zDi3jqcKXhGb9DjXd/b5GNQh1r0W2m7Nh1PiDqICWLztYSLC9W2rGJLQicJLkJV vQaLcj586jMvnUUyYXEWKZrWIkOwlVxt8BVWhzaaVmG0jXEdwFWN9gHWX0LrItS1V8od 5q9k2anOv1sbF+n64QVKf1ygE9yhpPB7+G+6iBejyO4gAutu0AH9biGmPSrZJ/HtPE0s 5luyy+NxL9oxOx4gH0knEj2zkSays5U9/Ay7NYrfNtq+IILKdNvLRezwTtdJfDaDUfY1 mPHin0jqmFl0dcfefuXZRx8aTvLHif68o8cixvF6LEGk4sNMZVMzquj5Ydzy1bryIgzk ofRA== X-Gm-Message-State: AOAM532mHlGj7vDXbbLwGKmoSiaM8grZbSKmv279GGadAqrNjnz6HbDG 8Wadx4cEy08L/LN9Yl91t9I= X-Google-Smtp-Source: ABdhPJxjhy1cPQ5sXu4aliJd6Lg0Zz2nDX7uUHnILq9ujsYeaIbteb6OEVlEzaB66wtBMKCRj81tJw== X-Received: by 2002:a05:600c:21c5:: with SMTP id x5mr13850591wmj.27.1635538154332; Fri, 29 Oct 2021 13:09:14 -0700 (PDT) Received: from nbbrfq (dynamic-2bq7di4u2lfl4qjka9-pd01.res.v6.highway.a1.net. [2001:871:227:33a8:f6a3:c58c:7641:e771]) by smtp.gmail.com with ESMTPSA id f18sm6771384wrg.3.2021.10.29.13.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:09:14 -0700 (PDT) Date: Fri, 29 Oct 2021 22:09:07 +0200 From: Bernhard Reutner-Fischer To: Harald Anlauf via Gcc-patches Cc: rep.dot.nop@gmail.com, Harald Anlauf , fortran@gcc.gnu.org Subject: Re: [PATCH,FORTRAN 28/29] Free type-bound procedure structs Message-ID: <20211029220907.04654d89@nbbrfq> In-Reply-To: References: <20180905145732.404-29-rep.dot.nop@gmail.com> <20211029020551.11a62076@nbbrfq> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2021 20:09:17 -0000 On Fri, 29 Oct 2021 21:36:26 +0200 Harald Anlauf via Gcc-patches wrote: > Dear Bernhard, all, > > Am 29.10.21 um 02:05 schrieb Bernhard Reutner-Fischer via Gcc-patches: > > >> diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c > >> index 53c760a6c38..cde34c67482 100644 > >> --- a/gcc/fortran/symbol.c > >> +++ b/gcc/fortran/symbol.c > > >> @@ -5052,7 +5052,7 @@ gfc_get_typebound_proc (gfc_typebound_proc *tb0) > >> > >> result = XCNEW (gfc_typebound_proc); > >> if (tb0) > >> - *result = *tb0; > >> + memcpy (result, tb0, sizeof (gfc_typebound_proc));; > >> result->error = 1; > >> > >> latest_undo_chgset->tbps.safe_push (result); > > > > > > please forgive me, but frankly speaking, I don't like this change. > > It seems to serve no obvious purpose other than obfuscating the code > and defeating the compiler's ability to detect type mismatches. mhm okay. IIRC these are folded to memcpy early on and in some projects with certain optimization levels results in an unobvious call to memcpy (which poses trouble if you want to avoid relocations at all cost which this might trigger if pulling in memcpy unexpectedly). f951 of course is not in the camp to bother much about this so i admit the change might stem from a tinfoil-hat moment of mine and might not be appropriate here. Although i don't buy the argument of the possibility of papering over type-mismatches in this particular case (the incoming arg is typed gfc_typebound_proc*, the result is typed gfc_typebound_proc*, the allocation is casted to gfc_typebound_proc*) we can certainly revert that hunk if folks prefer. > > I would not have OKed that part of the patch. For reference: gcc/fortran/symbol.c gfc_typebound_proc* gfc_get_typebound_proc (gfc_typebound_proc *tb0) { gfc_typebound_proc *result; result = XCNEW (gfc_typebound_proc); if (tb0) memcpy (result, tb0, sizeof (gfc_typebound_proc)); result->error = 1; latest_undo_chgset->tbps.safe_push (result); return result; } And i did - *result = *tb0; + memcpy (result, tb0, sizeof (gfc_typebound_proc)); > > Harald >