From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id 398603858D33 for ; Fri, 26 Jan 2024 15:13:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 398603858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 398603858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.18.0.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706282040; cv=none; b=OA+y5rpa+Ae0Ng0nfHcD2dmJkH/ohpXbAYrndPnT6fKjaTEXPLqWmUrrsi1d83XlDq1tKFrsaYlrkgh+VLY+VcnCIhFfgjAM/Ba2VfT0wMbCRlUMCquO1GQiSxYfvegkTqAhFttrurBn7ciedJBlEdidHufz01CNRRYP9undG04= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706282040; c=relaxed/simple; bh=vDQ8ZD/PfLk+037DP+G/wa/P4LVaz2/EdY6wbGHqs/k=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=MbAALZvi2bYhbfPmGrx92nqUtATrtQzmu0ez8FkWZRHt8IDDtPd9gqM7kHwiMNh8GJy4FWGQiblqGpoV5JJtyWHpk6Dm5pY3xoSWc8Lj2PSurLEsN0zB29eVCqPXzcsZSC6ZLdpZ8x7327JOw5c8iTxboV3Z+JQgajGNcAyqDBU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4TM1S45MQ4z1qsP4; Fri, 26 Jan 2024 16:13:56 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4TM1S44pnsz1qqlb; Fri, 26 Jan 2024 16:13:56 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id pDhYc6UHAfRV; Fri, 26 Jan 2024 16:13:56 +0100 (CET) X-Auth-Info: Uv0rLpuFh+0foUdzxvlysQZXU37QdxGLpwTDFywSLyI0rbiNMx4fwclZFegj65Gv Received: from igel.home (aftr-62-216-202-33.dynamic.mnet-online.de [62.216.202.33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 26 Jan 2024 16:13:56 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id B9F312C1320; Fri, 26 Jan 2024 16:13:55 +0100 (CET) From: Andreas Schwab To: Alejandro Colomar Cc: libc-alpha@sourceware.org Subject: Re: free(3) const void * In-Reply-To: (Alejandro Colomar's message of "Fri, 26 Jan 2024 14:21:13 +0100") References: X-Yow: My LIBRARY CARD expired... Date: Fri, 26 Jan 2024 16:13:55 +0100 Message-ID: <87y1cc3z64.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Jan 26 2024, Alejandro Colomar wrote: > It is sometimes (often?) useful to allocate some object, write > immediately to it, and then use it read-only. The standard definition > of free() forces the programmer to keep a non-const pointer around just > for the sake of freeing, which is unnecessarily dangerous. It is even more dangerous to pretend that the contents are unmodified, when in fact they are no longer accessible (the memory can be reused any time in any way). -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."