[LLVMbugs] [Bug 24168] New: #including files from /sys on Linux adds extra null characters
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 17 11:21:30 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: ncraun at gmail.com
CC: llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150717/10a83c28/attachment.html>
More information about the llvm-bugs
mailing list