From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1611) id 60162385E836; Thu, 2 May 2024 21:42:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60162385E836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1714686163; bh=Hax8bO1tXrKMgF1ZFsBl56wmiRr6k7cPK67I4GE2UhE=; h=To:Subject:Date:From:From; b=tVIp7PIOE/Gynabde3pp3OWhxGof8zdrMW1XW1rCC5IdSA0DVGPaYj2zTg6QKGkpl 8Nps7WaojjJZ+x2d9l0Ww5j04u3dp8meBJszpUmxnY6pQ0q90guGxW33zgfxvBPSFz T/+Pbaeh5RgBANe0F3DP2cCIRLiO/X2lTkBDEDvs= To: gcc-cvs-wwwdocs@gcc.gnu.org Subject: gcc-wwwdocs branch master updated. d2323d3efa30008ed05519a398eb7fe1e9b446d3 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 6c84b7b936a085c13e1f33f2028317fe31bbbcd8 X-Git-Newrev: d2323d3efa30008ed05519a398eb7fe1e9b446d3 Message-Id: <20240502214243.60162385E836@sourceware.org> Date: Thu, 2 May 2024 21:42:43 +0000 (GMT) From: Martin Jambor List-Id: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gcc-wwwdocs". The branch, master has been updated via d2323d3efa30008ed05519a398eb7fe1e9b446d3 (commit) from 6c84b7b936a085c13e1f33f2028317fe31bbbcd8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d2323d3efa30008ed05519a398eb7fe1e9b446d3 Author: Martin Jambor Date: Thu May 2 23:40:22 2024 +0200 Describe gcc target pragma changes in gcc-14/porting_to.html Adding a subsection on how gcc target pragma changed in GCC 14 in the corresponding porting-to document. diff --git a/htdocs/gcc-14/porting_to.html b/htdocs/gcc-14/porting_to.html index c825a68e..a20d82c2 100644 --- a/htdocs/gcc-14/porting_to.html +++ b/htdocs/gcc-14/porting_to.html @@ -514,6 +514,48 @@ be included explicitly when compiling with GCC 14: +

Pragma GCC target now affects preprocessor symbols

+ +

+The behavior of pragma GCC target and specifically how it affects ISA +macros has changed in GCC 14. In GCC 13 and older, the GCC +target pragma defined and undefined corresponding ISA macros in +C when using the integrated preprocessor during compilation but not +when the preprocessor was invoked as a separate step or when using +the -save-temps option. In C++ the ISA macro definitions +were performed in a way which did not have any actual effect. + +In GCC 14 C++ behaves like C with integrated preprocessing in earlier +versions. Moreover, in both languages ISA macros are defined and +undefined as expected when preprocessing separately from compilation. + +

+This can lead to different behavior, especially in C++. For example, +a part of the C++ snippet below will be (silently) compiled for an +incorrect instruction set by GCC 14. + +

+  #if ! __AVX2__
+  #pragma GCC push_options
+  #pragma GCC target("avx2")
+  #endif
+
+  /* Code to be compiled for AVX2. */
+
+  /* With GCC 14, __AVX2__ here will always be defined and pop_options
+  never invoked. */
+  #if ! __AVX2__
+  #pragma GCC pop_options
+  #endif
+
+  /* With GCC 14, all following functions will be compiled for AVX2
+  which was not intended. */
+
+ +

+The fix in this case is to remember whether pop_options +needs to be performed in a new user-defined macro. + ----------------------------------------------------------------------- Summary of changes: htdocs/gcc-14/porting_to.html | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) hooks/post-receive -- gcc-wwwdocs