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 801f3ad85b22a5da5114bfb47d74c94033806f24 (commit) via 4b61405659dbbfd9312e90e5bf6bfc224eabe3a4 (commit) from 6b798c7ed7aa889dd2c0f7f252b4d099b3cfbc22 (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 801f3ad85b22a5da5114bfb47d74c94033806f24 Author: David Malcolm <dmalc...@redhat.com> Date: Wed Jan 15 14:08:24 2025 -0500 gcc-15/porting_to: c23-fn-decls-without-parameters diff --git a/htdocs/gcc-15/porting_to.html b/htdocs/gcc-15/porting_to.html index 39598b93..c446e309 100644 --- a/htdocs/gcc-15/porting_to.html +++ b/htdocs/gcc-15/porting_to.html @@ -41,7 +41,69 @@ If your code relies on older versions of the C standard, you will need to either add <a href="https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-std-1">-std=</a> to your build flags, or port your code to C23. -<!-- C23 brings the following changes: --> +C23 brings the following changes: + +<h4 id="c23-fn-decls-without-parameters">Function declarations without parameters</h4> +<p> + The meaning of function declarations of the form + <code>rettype identifier ();</code> + such as + <code>char *strstr ();</code> + changed in C23. +</p> +<p> + In C17 and earlier, such function declarators specified no information + about the number or types of the parameters of the function (C17 6.7.6.3), + requiring users to know the correct number of arguments, with each passed + argument going through default argument promotion. +</p> +<p> + In C23 such declarations mean <code>(void)</code> i.e. a function taking + no arguments, which can lead to build failures on code that relied on + the earlier meaning, such as in + <a href="https://godbolt.org/z/11hzWYEeK">this example</a>: +</p> +<pre><code> +#include <signal.h> + +void test() +{ + void (*handler)(); + handler = signal(SIGQUIT, SIG_IGN); +} + +<source>: In function 'test': +<source>:6:11: error: assignment to 'void (*)(void)' from incompatible pointer type '__sighandler_t' {aka 'void (*)(int)'} [-Wincompatible-pointer-types] + 6 | handler = signal(SIGQUIT, SIG_IGN); + | ^ +In file included from <source>:1: +/usr/include/signal.h:72:16: note: '__sighandler_t' declared here + 72 | typedef void (*__sighandler_t) (int); + | ^~~~~~~~~~~~~~ +</code></pre> +<p> + Code such as the above relying on a non-zero number of parameters (such + as a single <code>int</code>) can be fixed for C23 by adding the correct + parameters to the function declarator, such as via: +</p> +<pre><code> + void (*handler)(int); +</code></pre> +<p> + In other cases the code is simply missing a <code>#include</code> of + the correct header, such as with: +<pre><code> + void *malloc(); +</code></pre> +<p> + These can be fixed by including the correct header and removing the + non-prototype declaration. +</p> +<p> + Alternatively you can use + <a href="https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-std-1">-std=</a> + to select an earlier version of the C standard. +</p> <h4 id="c23-new-keywords">New keywords</h4> <p> commit 4b61405659dbbfd9312e90e5bf6bfc224eabe3a4 Author: David Malcolm <dmalc...@redhat.com> Date: Wed Jan 15 14:53:57 2025 -0500 gcc-15/changes: add "C23 by default:" to <li> Tweak to help readability by adding a prefix to the <li> diff --git a/htdocs/gcc-15/changes.html b/htdocs/gcc-15/changes.html index 98d85cf9..171c3db4 100644 --- a/htdocs/gcc-15/changes.html +++ b/htdocs/gcc-15/changes.html @@ -101,7 +101,8 @@ a work-in-progress.</p> <h3 id="c">C</h3> <ul> - <li>GCC 15 changes the default language version for C compilation from + <li>C23 by default: GCC 15 changes the default language version + for C compilation from <a href="https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-std-1">-std=gnu17</a> to <a href="https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-std-1">-std=gnu23</a>. ----------------------------------------------------------------------- Summary of changes: htdocs/gcc-15/changes.html | 3 +- htdocs/gcc-15/porting_to.html | 64 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) hooks/post-receive -- gcc-wwwdocs