[llvm-bugs] [Bug 24630] New: -Wnonnull should not warn when in an unevaluated context.

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 30 13:53:17 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24630

            Bug ID: 24630
           Summary: -Wnonnull should not warn when in an unevaluated
                    context.
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eric at efcs.ca
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Currently when a function annotated with __attribute__((nonnull)) is called in
an unevaluated context with a null pointer a -Wnonnull warning is emitted. 
However it is useful to be able to pass null pointers to non-null parameters
within meta-programming. For this reason I don't think the following code
should produce a warning with -Wnonnull.

// clang++ -c -fsyntax-only  -Wnonnull  test.cpp 
int foo(int* __attribute__((nonnull))) { return 42; }
int x = sizeof(foo(0));

Note: g++ does not emit a warning on this code.

-- 
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/20150830/720d33bc/attachment.html>


More information about the llvm-bugs mailing list