Bug 87626

Summary: Named address spaces don't work in standard-conforming mode, but macros for them are defined
Product: gcc Reporter: Rich Felker <bugdal>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: fw, ssbssa, tschwinge
Priority: P3 Keywords: addr-space
Version: unknown   
Target Milestone: ---   
Host: Target: x86_64-*-*, i?86-*-*
Build: Known to work:
Known to fail: Last reconfirmed: 2021-08-19 00:00:00

Description Rich Felker 2018-10-16 19:56:33 UTC
When invoked in standards conforming mode, e.g. -std=c99, gcc on x86 defined __SEG_FS and __SEG_GS but they __seg_fs and __seg_gs keywords do not work and produce errors.

This is because c/c-decl.c: c_register_addr_space explicitly refuses to register the keyword if flag_no_asm is set, presumably because some targets define address space names that are not in the reserved namespace.

Either the macros __SEG_* should be suppressed when the functionality they represent is not available, or it should be fixed to work in all cases. I would highly prefer the latter. A simple fix would be only returning without doing anything if word[0]!='_'||word[1]!='_'. A better fix might be automatically registering the __-prefixed version if word itself is not __-prefixed, and registering both when flag_no_asm is not set.
Comment 1 Thomas Schwinge 2021-08-19 10:50:46 UTC
Confirmed, and see also PR69549 "Named Address Spaces does not compile in C++" where similarly it has been noticed that the macros also are defined in C++ mode, yet the functionality not being supported.