On Tue, Apr 30, 2024 at 11:12:30PM +0200, Martin Jambor wrote:
> Would the following then perhaps describe the situation accurately?
> Note that I have moved the whole thing to C++ section because it seems
> porting issues in C because of this are quite unlikely.
>
> Michal, I assume that the file where this issue happened was written in
> C++, right?
>
> Martin
>
>
>
> diff --git a/htdocs/gcc-14/porting_to.html b/htdocs/gcc-14/porting_to.html
> index c825a68e..1e67b0b3 100644
> --- a/htdocs/gcc-14/porting_to.html
> +++ b/htdocs/gcc-14/porting_to.html
> @@ -514,6 +514,51 @@ be included explicitly when compiling with GCC 14:
> </li>
> </ul>
>
> +<h3 id="gcc-targte-pragma">Pragma GCC Target now affects preprocessor
> symbols</h4>
I'd use lowercase Target here
> +
> +<p>
> +The behavior of pragma GCC Target and specifically how it affects ISA
And here as well, perhaps even <code>#pragma GCC target</code>.
Otherwise LGTM.
> +macros has changed in GCC 14. In GCC 13 and older, the <code>GCC
> +target</code> pragma defined and undefined corresponding ISA macros in
> +C when using integrated preprocessor during compilation but not when
> +preprocessor was invoked as a separate step or when using -save-temps.
> +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.
> +
> +<p>
> +This can lead to different behavior, especially in C++. For example,
> +functions the C++ snippet below will be (silently) compiled for an
> +incorrect instruction set by GCC 14.
> +
> +<pre>
> + #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 called. */
> + #if ! __AVX2__
> + #pragma GCC pop_options
> + #endif
> +
> + /* With GCC 14, all following functions will be compiled for AVX2
> + which was not intended. */
> +</pre>
> +
> +<p>
> +The fix in this case would be to remember
> +whether <code>pop_options</code> needs to be performed in a new
> +user-defined macro.
> +
> +
> +
> <!-- <h2 id="fortran">Fortran language issues</h2> -->
>
> </body>
Jakub