Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362442

Summary: The float-versions of the math-functions are not indexed.
Product: [Tools] CDT Reporter: Missing name <Liganic>
Component: cdt-indexerAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: major    
Priority: P3 CC: cdtdoug, eclipse.sprigogin
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Missing name CLA 2011-10-30 19:06:47 EDT
Build Identifier: M20110909-1335

Minimalistic test case:
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	cout<<sqrtf(3)<<endl;
	return 0;
}

produces:
Function 'sqrtf' could not be resolved
Invalid overload of 'endl'

However the code compiles fine through eclipse.

Reproducible: Always
Comment 1 Elena Laskavaia CLA 2011-11-03 15:17:35 EDT
Parser? Or Indexer?
Comment 2 Missing name CLA 2011-11-03 15:27:14 EDT
> Parser? Or Indexer?
I am not sure about the difference but in the test case the errors are marked red in the code since sqrtf is provided by glibc under C99 and thus not explicitly declared in a header file. Environment is current Arch Linux.
Comment 3 Markus Schorn CLA 2011-11-04 02:24:11 EDT
The code example is C++, not C99?
In any way, 'sqrtf' is defined in math.h and is found correctly in my environment. In case the include-search path is setup correctly and you do see the problem, try to create a self-contained example (e.g. by copying the necessary system-headers into a project) and attach it to the bug.
Comment 4 Missing name CLA 2011-11-04 11:37:49 EDT
> The code example is C++, not C99?
The code is C++ but only functions which need --std=c99 seem to be broken. To be precise sqrtf, fabsf etc.

> In any way, 'sqrtf' is defined in math.h and is found correctly in my
> environment. In case the include-search path is setup correctly and you do see
> the problem, try to create a self-contained example (e.g. by copying the
> necessary system-headers into a project) and attach it to the bug.
I am not sure how to narrow it down. I tried in a freshly installed Ubuntu system and it works (as expected) but F3 on sqrtf brings me to sqrt(!) in mathcalls.h while F3 in Arch just says that sqrtf is not in the index.

The same sqrt exists in mathcalls.h on my system in the set include path (/usr/include/bits/) but somehow CDT doesn't recognize it for sqrtf.
The only difference is: Ubuntu uses eglibc and Arch Linux glibc.
Comment 5 Markus Schorn CLA 2011-11-07 03:41:49 EST
The standard headers use the following pattern:

mathcalls.h:
   __MATHCALL (sqrt,, (_Mdouble_ __x));

math.h:
   #define __MATHCALL(function, suffix, args) \
           extern _Mdouble_ __MATH_PRECNAME(function,suffix) args

   #define _Mdouble_ 		double
   #define __MATH_PRECNAME(name,r)	name##r
   #include "mathcalls.h"
   #undef	_Mdouble_
   #undef	__MATH_PRECNAME

   #define _Mdouble_ 		float
   #define __MATH_PRECNAME(name,r) name##f##r
   #include "mathcalls.h"
   #undef	_Mdouble_
   #undef	__MATH_PRECNAME


This pattern is not yet covered by fix for bug 197989, see bug 197989 comment 95
Comment 6 Missing name CLA 2011-11-07 08:42:14 EST
(In reply to comment #5)
> This pattern is not yet covered by fix for bug 197989, see bug 197989 comment
> 95
Is there a temporary work-around available which doesn't modify the code?
Comment 7 Markus Schorn CLA 2011-12-21 07:41:58 EST
Implemented as discussed in bug 197989 comment 95. I have optimized storing the significant macro dictionaries, with that the performance penalty in my boost test project is less than 5%.
Comment 8 CDT Genie CLA 2011-12-21 08:23:03 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 362442: Considering all expansions for significant macros.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=2dea3d4a339d49579b06d13399e66adb03556fd8