Bug 114875 - runtime/runtime.h should be updated to compile under C23
Summary: runtime/runtime.h should be updated to compile under C23
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: go (show other bugs)
Version: 14.0
: P3 enhancement
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords: internal-improvement
Depends on:
Blocks:
 
Reported: 2024-04-28 02:09 UTC by jeffrey.cliff
Modified: 2024-04-29 18:35 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-04-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jeffrey.cliff 2024-04-28 02:09:07 UTC

    
Comment 1 Andrew Pinski 2024-04-28 02:12:55 UTC
There is no comment on what is the issue here ...
Comment 2 jeffrey.cliff 2024-04-28 04:34:59 UTC
whoops, accidentally hit submit before I had all the details

tl;dr at least in gcc 14.1 [but probably elsewhere]

in
libgo/runtime/runtime.h

defines an enum of 

enum
{
        true    = 1,
        false   = 0,
};

which means that it doesn't compile under -std=gnu2x similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114216 

and more importantly - it's a header, which means *any code that uses it* also won't build.

it's an easy enough fix
add an if guard

#if __STDC_VERSION__ <= 201710L 
enum
{
        true    = 1,
        false   = 0,
};
#endif

this allows for runtime/runtime.h to be compliant with c23 and previous versions.

testing the fix now
Comment 3 Andrew Pinski 2024-04-28 04:44:41 UTC
Considering this file is written in C11 (or C17), the changes does not need to happen right away.
Comment 4 Andrew Pinski 2024-04-28 04:46:18 UTC
(In reply to jeffrey.cliff from comment #2)
> and more importantly - it's a header, which means *any code that uses it*
> also won't build.

Considering it is an internal header to libgo and not installed, it just means any code that uses it must be written in C11/C17 rather than C23.
Comment 5 Andrew Pinski 2024-04-28 04:48:37 UTC
Also it is not just true/false.
It is:
typedef _Bool                   bool;

The rest looks ok too.
Comment 6 Ian Lance Taylor 2024-04-29 18:35:12 UTC
Should be fixed on tip by 678dc5e85053f1a1ca76997eec95ba8823bb6830.  Thanks.