[LLVMbugs] [Bug 19015] New: Warning fixit induces lookup failure + error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Mar 1 08:02:17 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=19015

            Bug ID: 19015
           Summary: Warning fixit induces lookup failure + error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Axel.Naumann at cern.ch
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I'm not claiming this is a beauty, but:


// T.h"
#include <stdlib.h>
#include <cstdlib>

using namespace std;

inline long MyAbs1(long d) { return ::labs(d); }
inline long MyAbs2(long d) { return ::abs(d); }

int fun(long d) {
   return MyAbs1(d) + MyAbs2(d);
}


compiled as

clang -fsyntax-only -x c++ T.h

causes

T.h:7:37: warning: absolute value function 'abs' given an argument of type
'long' but has parameter of type
      'int' which may cause truncation of value [-Wabsolute-value]
inline long MyAbs2(long d) { return ::abs(d); }
                                    ^
T.h:7:37: error: reference to 'labs' is ambiguous
inline long MyAbs2(long d) { return ::abs(d); }
                                    ^
/usr/include/stdlib.h:772:17: note: candidate found by name lookup is 'labs'
extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
                ^
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/cstdlib:117:11:
note: candidate found by name
      lookup is 'std::labs'
  using ::labs;
          ^
1 warning and 1 error generated.



The error is unexpected and seems to be triggered by a failed lookup from fixit
which might ignore the original lookup scope ("::"). I.e. the warning is good,
the error is not. That's with r202469.

-- 
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/20140301/e1aab3ae/attachment.html>


More information about the llvm-bugs mailing list