public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor @ 2022-11-21 14:16 coder5506 at pobox dot com 2022-11-21 14:21 ` [Bug preprocessor/107794] " redi at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: coder5506 at pobox dot com @ 2022-11-21 14:16 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107794 Bug ID: 107794 Summary: can't use the string "linux-" via stringizing in the preprocessor Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: coder5506 at pobox dot com Target Milestone: --- The program (scratch.c): #include <stdio.h> #define str(s) #s #define xstr(s) str(s) #define STRING linux-aarch64.cf int main() { printf("%s\n", xstr(STRING)); } The output (running ./a.out): 1-aarch64.cf Expected output: linux-aarch64.cf It works as expected for any string not exactly matching "linux-", but in everything I've tried "linux-" is always shortened to "l-" even when not at the beginning of the string. > the exact version of GCC; > the system type; gcc 10.2.1 on Debian 11 x86_64 gcc 10.2.1 on Armbian (Debian 11) aarch64 gcc 11.3.0 on Arbmian (Debian 11) aarch64 > the options given when GCC was configured/built; In building 11.3.0, I passed "--enable-languages=c --disable-multilib" > the complete command line that triggers the bug; gcc -Wall -Wextra -save-temps scratch.c > the compiler output (error messages, warnings, etc.); and none > the preprocessed file (*.i*) that triggers the bug, generated by adding -save-temps to the complete compilation command Truncated, but here's how it ends # 858 "/usr/include/stdio.h" 3 4 extern int __uflow (FILE *); extern int __overflow (FILE *, int); # 873 "/usr/include/stdio.h" 3 4 # 2 "scratch.c" 2 # 5 "scratch.c" int main() { printf("%s\n", "1-aarch64.cf"); } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug preprocessor/107794] can't use the string "linux-" via stringizing in the preprocessor 2022-11-21 14:16 [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor coder5506 at pobox dot com @ 2022-11-21 14:21 ` redi at gcc dot gnu.org 2022-11-21 14:24 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2022-11-21 14:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107794 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- "linux" is a predefined macro. Compile with -std=c17 instead of the default -std=gnu17 to disable that. See https://gcc.gnu.org/onlinedocs/cpp/System-specific-Predefined-Macros.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug preprocessor/107794] can't use the string "linux-" via stringizing in the preprocessor 2022-11-21 14:16 [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor coder5506 at pobox dot com 2022-11-21 14:21 ` [Bug preprocessor/107794] " redi at gcc dot gnu.org @ 2022-11-21 14:24 ` pinskia at gcc dot gnu.org 2022-11-21 14:33 ` coder5506 at pobox dot com 2022-11-21 16:25 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-11-21 14:24 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107794 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Why do you think this is a bug? linux is defined somewhere, either by gcc or by the headers. I think it is predefined and disabled by using -std=c11. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug preprocessor/107794] can't use the string "linux-" via stringizing in the preprocessor 2022-11-21 14:16 [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor coder5506 at pobox dot com 2022-11-21 14:21 ` [Bug preprocessor/107794] " redi at gcc dot gnu.org 2022-11-21 14:24 ` pinskia at gcc dot gnu.org @ 2022-11-21 14:33 ` coder5506 at pobox dot com 2022-11-21 16:25 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: coder5506 at pobox dot com @ 2022-11-21 14:33 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107794 --- Comment #3 from Eric Sessoms <coder5506 at pobox dot com> --- I thought it was a bug b/c it worked as I expected in clang. You're right, I didn't think it through. Sorry to have wasted your time, but thanks for setting me straight. Please close, invalid. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug preprocessor/107794] can't use the string "linux-" via stringizing in the preprocessor 2022-11-21 14:16 [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor coder5506 at pobox dot com ` (2 preceding siblings ...) 2022-11-21 14:33 ` coder5506 at pobox dot com @ 2022-11-21 16:25 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-11-21 16:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107794 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Invalid because linux is a predefined as mentioned. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-21 16:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-11-21 14:16 [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor coder5506 at pobox dot com 2022-11-21 14:21 ` [Bug preprocessor/107794] " redi at gcc dot gnu.org 2022-11-21 14:24 ` pinskia at gcc dot gnu.org 2022-11-21 14:33 ` coder5506 at pobox dot com 2022-11-21 16:25 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).