Bug 114773 - Raw string literals are not supported in C89 mode
Summary: Raw string literals are not supported in C89 mode
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2024-04-18 18:19 UTC by Sirraide
Modified: 2024-04-19 11:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sirraide 2024-04-18 18:19:17 UTC
I’m currently working on supporting raw string literals in C in Clang like GCC does, and we noticed that GCC doesn’t support them in `-std=gnu89` mode, only in `-std=gnu99` mode and later (https://godbolt.org/z/hahja6Y87). 

Is this intentional or a bug?
Comment 1 Andrew Pinski 2024-04-18 18:27:12 UTC
https://gcc.gnu.org/gcc-4.5/changes.html

Looks like it is on purpose:
C++0x raw strings are supported for C++ and for C with -std=gnu99.



https://inbox.sourceware.org/gcc-patches/20080912132007.GA9666@hs20-bc2-1.build.redhat.com/
Comment 2 Sirraide 2024-04-18 18:29:48 UTC
Thanks!
Comment 3 Jakub Jelinek 2024-04-18 18:36:23 UTC
-std=gnu89 is meant for really old programs, and the raw string literal support changes behavior, so it isn't a pure extension on what wasn't valid before, e.g. consider
#define R
#define b
const char * square(void) {
    return R"(a"b"a)";
}
in -std=c89 or -std=gnu89 this is return "(aa)"; while in -std=gnu99 return "a\"b\"a";
Comment 4 Sirraide 2024-04-18 18:50:36 UTC
Yeah, we figured that that was why they’re not supported in `-gnu89` mode, but I thought I’d ask just to be sure.
Comment 5 Xi Ruoyao 2024-04-19 11:15:13 UTC
Then this isn't a valid bug report.
Comment 6 Xi Ruoyao 2024-04-19 11:16:47 UTC
Oops, the mouse scroll wheel is too sensitive and I selected the wrong resolution :(.