Description
Greetings,
I may have found a small set of constants whose values were included in libc as decimal literals while in fact they were written as octal literals in C. I believe this is the case because in C an integer literal that begins with a '0' is considered an octal literal, whereas in Rust the leading '0' is silently discarded.
I first noticed this while inspecting the value of O_NONBLOCK
of another platform for a project of mine, and I noticed it had this declaration on Linux uClibc x86_64, which was inconsistent with all the other related values. This convinced me to investigate further, and I ran a RegExp against libc's codebase, which resulted in a small subset of constants (most are related to fcntl.h
):
Before filing this issue, in order to be as sure and detailed as possible, I also went and gave a read to uClibc's Linux fcntl.h
file, which uses in fact octal literals to declare the affected constants' values.
TL;DR
The constants listed above were likely copy-pasted from their respective headers and the subtle differences in integer literal rules from Rust and C lead to "wrong" values sneaking into the library...
unless I missed something and rustc
is able to correctly interpret those literals as octals, which I unfortunately haven't been able to test on a Linux machine at the time of writing.