[LLVMbugs] [Bug 10076] New: Simple mixup of "abs" and "fabs" leads to 65-line cascade of error messages

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 3 15:46:34 PDT 2011


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

           Summary: Simple mixup of "abs" and "fabs" leads to 65-line
                    cascade of error messages
           Product: new-bugs
           Version: 2.8
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: arthur.j.odwyer at gmail.com
                CC: llvmbugs at cs.uiuc.edu


This wouldn't be terribly shocking if it were a different compiler, or if C++
templates were involved, but it really surprised me that:
(A) anything could lead to such an icky-looking dump from the normally
user-friendly Clang front-end;
(B) the majority of the dump seems to have been triggered by Clang's attempt to
be *more* helpful by suggesting that I might have misspelled "fabs"; and
(C) that it apparently takes seven or eight levels of macro magic and compiler
builtins to implement "fabs" in the math headers. Couldn't this be simplified
somehow?

Simple test case:

cat >test.cc <<EOF
#include <math.h>  /* whoops! the user meant <stdlib.h> */
int main() { return abs(0); }
EOF
clang++ -c test.cc

I've pasted the output I got below (except multiply that by 6 since I used
"abs" six times in my original code, and every instance generated a new 60-line
cascade of errors). 

$ clang++ Narrate.cc
Narrate.cc:143:9: error: use of undeclared identifier 'abs'; did you mean
      'fabs'?
    if (abs(fa.x - fb.x) <= 3) relatedness += 2;
        ^~~
        fabs
In file included from Narrate.cc:3:
In file included from /usr/include/math.h:71:
/usr/include/bits/mathcalls.h:182:1: note: 'fabs' declared here
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
^
In file included from Narrate.cc:3:
/usr/include/math.h:60:3: note: instantiated from:
  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  ^
/usr/include/math.h:62:3: note: instantiated from:
  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
  ^
/usr/include/math.h:65:15: note: instantiated from:
  extern type __MATH_PRECNAME(function,suffix) args __THROW
              ^
/usr/include/math.h:68:33: note: instantiated from:
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
                                ^
In file included from Narrate.cc:3:
In file included from /usr/include/math.h:71:
/usr/include/bits/mathcalls.h:182:1: note: instantiated from:
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
^
In file included from Narrate.cc:3:
/usr/include/math.h:60:3: note: instantiated from:
  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  ^
/usr/include/math.h:62:3: note: instantiated from:
  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
  ^
/usr/include/math.h:65:15: note: instantiated from:
  extern type __MATH_PRECNAME(function,suffix) args __THROW
              ^
In file included from Narrate.cc:3:
In file included from /usr/include/math.h:71:
/usr/include/bits/mathcalls.h:182:1: note: instantiated from:
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
^
In file included from Narrate.cc:3:
/usr/include/math.h:60:3: note: instantiated from:
  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  ^
/usr/include/math.h:62:3: note: instantiated from:
  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
  ^
In file included from Narrate.cc:3:
In file included from /usr/include/math.h:71:
/usr/include/bits/mathcalls.h:182:1: note: instantiated from:
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
^
In file included from Narrate.cc:3:
/usr/include/math.h:60:3: note: instantiated from:
  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  ^
In file included from Narrate.cc:3:
In file included from /usr/include/math.h:71:
/usr/include/bits/mathcalls.h:182:1: note: instantiated from:
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
^
/usr/include/bits/mathcalls.h:182:14: note: instantiated from:
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
             ^
1 error generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list