Skip to content

Simple mixup of "abs" and "fabs" leads to 65-line cascade of error messages #10448

@Quuxplusone

Description

@Quuxplusone
Bugzilla Link 10076
Resolution FIXED
Resolved on Aug 09, 2011 04:15
Version 2.8
OS All

Extended Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions