This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug preprocessor/66909] Internal Compiler Error when #including files from /sys on Linux


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

--- Comment #2 from Nate Craun <nate at natecraun dot net> ---
It seems that clang has a similar issue. I added an entry on their bug tracker
here: https://llvm.org/bugs/show_bug.cgi?id=24168

As mentioned in clang's bug tracker:

I think the problem is related to the use of stat. For example, the manpage for
stat() mentions:

"For  most files under the /proc directory, stat() does not return the file
size in the st_size field; instead the field is returned with the value 0."

To test this out I wrote another test that tries to #include a file from /proc.

#include "/proc/meminfo"

However this did not #include the text from the /proc/meminfo at all. Running
the preprocessor on this produced an empty file. This is presumably because
stat() is saying /proc/meminfo has zero bytes.

I don't know if this #including files from proc bug should have its own issue
or not, as it seems to be related to the same underlying issue of stat()
behaving differently on procfs, sysfs, and maybe others.

Like I said before though, I don't have any practical use for #including files
from /proc or /sys. But the preprocessor should still be able to do this
textual inclusion correctly.

I haven't tried this out yet, but now I'm wondering if #include will have
issues on other special files on Linux: pipes, sockets, dev files, etc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]