Bug 87626 - Named address spaces don't work in standard-conforming mode, but macros for them are defined
Summary: Named address spaces don't work in standard-conforming mode, but macros for t...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: addr-space
Depends on:
Blocks:
 
Reported: 2018-10-16 19:56 UTC by Rich Felker
Modified: 2023-12-06 15:01 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.