public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "coder5506 at pobox dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/107794] New: can't use the string "linux-" via stringizing in the preprocessor
Date: Mon, 21 Nov 2022 14:16:37 +0000	[thread overview]
Message-ID: <bug-107794-4@http.gcc.gnu.org/bugzilla/> (raw)

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");
}

             reply	other threads:[~2022-11-21 14:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 14:16 coder5506 at pobox dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107794-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).