Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126241 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 578E71ADB50 for ; Thu, 30 Jan 2025 15:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738252096; bh=gNI9fnN8o4JgJQU34frhZRxUH4Iu68fQ45u2udHsa4Q=; h=Date:From:To:Subject:In-Reply-To:References:From; b=K1Fb/jwdo0nBhTq2DODFJxEHh73tQHsw7fDx32Mhu5X+qp/k9B48b5p5mZemPRWvR ozkB7zCrH8MMRH+NCRaD7h6rWAndhR+iwxPnGJWWzWosc0RUURDcrRPyAJ7JKLp06b Uh4xaor5PjRYql6wwguHWknCWFNUfJbd6Bb7C3m3E5r/ke7RwsXo/nWe0oNQm/1o5v g9AVFUBXj/T8Ifb/FtpVjJ+VBpNaiRfGsrQiLHTMNSzFoE4W1d1lzD6kklz+THzlQS jvGGrCPpKtm6e0atI33cKmUxHEuPseaTzJ3TrAyo0IYLioYTKPN2HH4/LV/IH2zjab ooFct46eRB+xA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B0E941804BB for ; Thu, 30 Jan 2025 15:48:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 30 Jan 2025 15:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1738252259; bh=2ztJuPHY556WUa12Ivbkznr0PcG7/i9kY5TpR2pnECA=; h=MIME-Version:Date:From:To:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=HemLt4YWYZy6+e6pHYRo+s3hGwwMueWWqKS2KJgyHlidXgjjA/A6KQ2WvKOtsYOZQ hM5T/E3he1gYoFG7P1ibCeZAJy1IJ3GzDgRFhn8rTC/q2m1VhIc/8k/LUP9PK003CR 3SuGox+qui/o6wIb3sUOFKbLDRnK0yODe5cLk/XCy+roIb28v9XILY1UKIW40Kn9fD xbH2ndbo8Q+0Hdv7AkqbiWQ1cCApeKRurY/fyi8eWkdJPcqDV5rFT/2uFbnq/12VaX DOwXbbooreyJyVVmKSZLmH2Iw3mgWWFbxQEZJqYf85PNAF2L/g68ju+P0Gb56I+J42 E0ONH/MnGa2DA== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 30 Jan 2025 16:50:59 +0100 To: php internals Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) In-Reply-To: References: <3f170549-cfd6-441e-b892-cf51d726dbe8@bastelstu.be> <3b4d9be8-9255-44ab-95c5-ea3045212cf4@app.fastmail.com> Message-ID: <55641ab50d80b8b375ef9aab296e76b8@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-01-29 23:48, schrieb Christian Schneider: > I guess another option would be to define a > function nop($_) {} > and then use > nop(outer()); > but my question is whether $_ = outer() and nop(outer()) will be > guaranteed to not being optimized in a way which causes the warning to > reappear. I don't know much about the optimizations being done but this > could be an issue in the future, no? For `$_` see my reply to Rob. For the function: OPcache will attempt to inline functions that only return a (implicit) return statement. However this only works if the function is defined in the same file, as OPcache currently cannot perform cross-file optimizations. I'd say that defining the `nop()` function in a dedicated file is currently the most reliable solution to prevent OPcache from optimizing away the usage in a backwards-compatible way. Of course the best solution is actually doing something useful with the return value, as the attribute is intended to point out when not using the return value is very likely to be wrong. We would expect it to be rarely necessary to just suppress the warning. Best regards Tim Düsterhus