https://llvm.org/bugs/show_bug.cgi?id=24168
Bug ID: 24168
Summary: #including files from /sys on Linux adds extra null
characters
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Hello,
I recently encountered a bug where #including files from /sys on Linux will
read extra null characters that are not originally in that file.
The bug can be reproduced by #including any file from /sys, for example:
bug.c:
#include "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"
This makes clang generate about several thousand warnings about null
characters:
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size:2:1968: warning:
null character ignored [-Wnull-character
However, if you run something like cat
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size you see that the
file does not have all these extra null characters. On my machine cat cat
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size just prints out
"64".
So somehow the preprocessor is reading many more null characters than are
actually in the file. Now of course there's probably no practical reason to
#include files from /sys, but still it should read the file in correctly
without appending extra null bytes.
I think the preprocessor is not correctly reading the file from the sysfs
virtual file system on /sys.
I am running clang version 3.5.0 on Linux kernel 4.0.6.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs