[cfe-dev] clang warns on libcxx chrono and string usage of user-defined literals

David Blaikie dblaikie at gmail.com
Tue Oct 1 09:54:40 PDT 2013


On Oct 1, 2013 9:48 AM, "Marshall Clow" <mclow.lists at gmail.com> wrote:
>
> On Oct 1, 2013, at 9:41 AM, Yaron Keren <yaron.keren at gmail.com> wrote:
>
>> I am calling clang using a custom driver, and it seems clang diagnostics
state is different than the command line driver. I'm looking into this
issue now.
>>
>> This aside, I think that clang turns off all warnings for system include
files, so compiling from the command line effectively hides this warning as
well as potential others.
>
>
> I don't think that's true; (the 'all warnings' part), but lang definitely
behaves somewhat differently when compiling a system header file.

Clang and other compilers definitely suppress a lot (if not all) warnings
in system headers as its generally assumed to be unactionable by an end
user, so not a useful thing to notify them of.

See a recent bug (or perhaps this was found/discussed internally) found in
libstdc++ involving a bool returning function that fell off the end. No
-Wreturn-type warning, just the sigill at runtime. If we're not already
building libc++ in such a way that it avoids the system header
suppressions, we probably should fix that for the sake of avoiding bugs
like this.

>
>> So the question is wether this is a real issue or not, as the suffixes
in chrono are lacking an underscore but are not user-defined but
system-defined.
>
>
> If you're not compiling a system include file, then that's a fine error.
> UDL's that do not start with '_' are reserved.
>
> But there has to be a way for libc++ to define them.
>
> I would say that this is not a real issue.
>
> -- Marshall
>
>
>> 2013/10/1 Marshall Clow <mclow.lists at gmail.com>
>>>
>>> On Sep 30, 2013, at 11:48 PM, Yaron Keren <yaron.keren at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Trying to compile libcxx using ToT clang results in several warnings
such as:
>>>>
>>>> libcxx/string:4169:24: warning: user-defined literal suffixes not
starting with '_' are reserved
>>>>     basic_string<char> operator "" s( const char *__str, size_t __len )
>>>>
>>>> libcxx/chrono:955:29: warning: user-defined literal suffixes not
starting with '_' are reserved
>>>>     constexpr chrono::hours operator"" h(unsigned long long __h)
>>>>                        ^
>>>> debugging, I see Sema::CheckLiteralOperatorDeclaration calling
NumericLiteralParser::isValidUDSuffix which returns true (valid) for the
"s" and "h" suffixes.  This prevents the second optional part of the
warning, "no literal will invoke this operator" but not the first one shown
above.
>>>
>>>
>>> I'm not seeing this at all  (on Mac OS).
>>>
>>> I just built ToT clang and then built libc++ - no warnings.
>>> Then I tried just building individual source files from libc++ to
check. No warnings either.
>>>
>>> $ /Sources/LLVM/build/llvm-cmake-nodebug/bin/clang++ --version
>>> clang version 3.4 (trunk 191753)
>>> Target: x86_64-apple-darwin12.5.0
>>> Thread model: posix
>>> $
>>> $ cd /Sources/LLVM/libcxx/lib
>>> $ TRIPLE=-apple- CXX=$LLVM/build/llvm-cmake-nodebug/bin/clang++
./buildit
>>> [ output snipped; but no warnings ]
>>> $
>>> $ TRIPLE=-apple- CXX=$LLVM/build/llvm-cmake-nodebug/bin/clang++
./buildit14
>>> [ buildit14 is a copy of buildit that sets "-std=c++1y" instead of
"-std=c++11" ]
>>> [ output snipped; but no warnings ]
>>> $
>>> $/Sources/LLVM/build/llvm-cmake-nodebug/bin/clang++ -c -g -Os -arch
i386 -arch x86_64 -nostdinc++ -std=c++11 -fstrict-aliasing -Wall -Wextra
-Wshadow -Wconversion -Wnewline-eof -Wpadded -Wmissing-prototypes
-Wstrict-aliasing=2 -Wstrict-overflow=4 -I../include ../src/chrono.cpp
>>> $
>>> $ /Sources/LLVM/build/llvm-cmake-nodebug/bin/clang++ -c -g -Os -arch
i386 -arch x86_64 -nostdinc++ -std=c++1y -fstrict-aliasing -Wall -Wextra
-Wshadow -Wconversion -Wnewline-eof -Wpadded -Wmissing-prototypes
-Wstrict-aliasing=2 -Wstrict-overflow=4 -I../include ../src/chrono.cpp
>>> $
>>>
>>>
>>> -- Marshall
>>>
>>> Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>
>>>
>>> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is
promptly moderated down to (-1, Flamebait).
>>>         -- Yu Suzuki
>>>
>>
>
> -- Marshall
>
> Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>
>
> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is
promptly moderated down to (-1, Flamebait).
>         -- Yu Suzuki
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131001/7c31726f/attachment.html>


More information about the cfe-dev mailing list