Bug 2336256

Summary: R fails to build with GCC 15 (C23 noreturn issues?)
Product: [Fedora] Fedora Reporter: Dave Malcolm <dmalcolm>
Component: RAssignee: Tom "spot" Callaway <spotrh>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: i.ucar86, jakub, r-maint-sig, spotrh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-01-15 21:29:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2333037    

Description Dave Malcolm 2025-01-07 22:03:17 UTC
I'm experimentally rebuilding rawhide with the not-yet-released GCC 15 to see if anything breaks, and to help write the porting guide.  See https://fedoraproject.org/wiki/User:Dmalcolm/gcc-15

My test build with GCC 15 failed:
https://copr.fedorainfracloud.org/coprs/dmalcolm/gcc-15-smoketest-3.failed/build/8476046/

whereas my test build with GCC 14 succeeded:
https://copr.fedorainfracloud.org/coprs/dmalcolm/gcc-15-smoketest-3.failed.checker/build/8477596/

Looking at the failure logs e.g.
https://download.copr.fedorainfracloud.org/results/dmalcolm/gcc-15-smoketest-3.failed/fedora-rawhide-x86_64/08476046-R/builder-live.log.gz

I see:

sys-std.c:1189:1: warning: 'noreturn' attribute ignored [-Wattributes]
 1189 | void Rstd_CleanUp(SA_TYPE saveact, int status, int runLast)
      | ^~~~
sys-std.c:1189:1: error: expected identifier or '(' before 'void'

I'm not yet sure what's causing this; possibly due to the change of default to C23 ?

Reproducible: Always

Comment 1 Dave Malcolm 2025-01-07 22:07:12 UTC
Looking at https://svn.r-project.org/R/trunk/src/unix/sys-std.c
the context seems to be:

/*
   R_CleanUp is invoked at the end of the session to give the user the
   option of saving their data.
   If ask == SA_SAVEASK the user should be asked if possible (and this
   option should not occur in non-interactive use).
   If ask = SA_SAVE or SA_NOSAVE the decision is known.
   If ask = SA_DEFAULT use the SaveAction set at startup.
   In all these cases run .Last() unless quitting is cancelled.
   If ask = SA_SUICIDE, no save, no .Last, possibly other things.
 */

attribute_hidden NORET
void Rstd_CleanUp(SA_TYPE saveact, int status, int runLast)
{

Comment 2 Dave Malcolm 2025-01-07 22:10:24 UTC
I'm guessing that "attribute_hidden" is defined in 
https://svn.r-project.org/R/trunk/src/include/Defn.h

which has:

#ifdef HAVE_VISIBILITY_ATTRIBUTE
# define attribute_visible __attribute__ ((visibility ("default")))
# define attribute_hidden __attribute__ ((visibility ("hidden")))
#else
# define attribute_visible
# define attribute_hidden
#endif

but I wasn't able to find a definition of "NORET".  Or maybe something else is going wrong.

Comment 3 Iñaki Ucar 2025-01-08 09:57:20 UTC
Upstream is aware of this AFAICT (see e.g. https://github.com/search?q=repo%3Awch%2Fr-source%20gcc%2015&type=code). So they will likely solve this in the next release.

Comment 4 Jakub Jelinek 2025-01-09 17:32:49 UTC
I think GCC in this spot only handles C23 attributes before GNU attributes, not the other way around, so
NORET attribute_hidden
void Rstd_CleanUp(SA_TYPE saveact, int status, int runLast)
{
would be ok but
attribute_hidden NORET
void Rstd_CleanUp(SA_TYPE saveact, int status, int runLast)
{
is not.

Comment 5 Iñaki Ucar 2025-01-15 21:29:07 UTC
And isn't this a GCC issue? Anyway, upstream provided a patch for now. Closing here.

Comment 6 Jakub Jelinek 2025-01-15 21:45:58 UTC
As clarified by C FE maintainer, it is intentional that way.  __attribute__ is a GNU extension and its placement is generally more forgiving, while the C23 standard clearly specifies where in the grammar they can appear and what they appertain to in each of those cases.