https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120418

            Bug ID: 120418
           Summary: embed testcases issue
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexey.lapshin at espressif dot com
  Target Milestone: ---

Almost all testcases for "#embed" are failing. Because they use "#embed
__FILE__".

The issue does not appear for such tests in case the working directory is the
same as the source's file directory. Or full path to the source file was passed
to GCC.


Explanation:

1. cd ./gcc/testsuite
2. gcc -std=c23 -Wconversion ./gcc.dg/cpp/embed-10.c
3. get "fatal error: ./gcc.dg/cpp/embed-10.c: No such file or directory"


Why does this happen?

1. __FILE__ macro is "./gcc.dg/cpp/embed-10.c"
2. "#embed __FILE__" acts like "#include" and start to look up the file from
source file directory. And looking for "./gcc.dg/cpp/./gcc.dg/cpp/embed-10.c".

I also tested it with "gcc:15.1.0" docker image, and strace gives the same as
for my toolchain. ("strace -f gcc -std=c23 -Wconversion
./gcc.dg/cpp/embed-10.c"):


[pid   167] openat(AT_FDCWD, "./gcc.dg/cpp/./gcc.dg/cpp/embed-10.c",
O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid   167] openat(AT_FDCWD, "./gcc.dg/cpp/embed-10.c", O_RDONLY) = 4
[pid   167] newfstatat(4, "", {st_mode=S_IFREG|0664, st_size=305, ...},
AT_EMPTY_PATH) = 0
[pid   167] read(4, "/* This is a comment with some U"..., 4096) = 305
[pid   167] read(4, "", 4096)           = 0
[pid   167] write(2, "\33[01m\33[K./gcc.dg/cpp/embed-10.c:"...,
327./gcc.dg/cpp/embed-10.c:6:8: fatal error: ./gcc.dg/cpp/embed-10.c: No such
file or directory



I guess testcases should be fixed, because gcc acts as expected

Reply via email to