View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001775CMakepublic2005-04-15 14:402006-10-04 14:41
ReporterBrad King 
Assigned ToBrad King 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001775: CheckFunctionExists and intrinsic functions
DescriptionThe current implementation of CHECK_FUNCTION_EXISTS looks for function foo like this:

char foo();
int main() { foo(); return 0; }

which works in C because there is no mangling so the function can exist with any signature in the standard library. This fails for "intrinsic" functions on Visual Studio optimizing compilers with the /O2 option. Functions like memcmp are builtin and have a signature known to the compiler. Then the call to it fails even though the function exists.

We could instead use this implementation:

char memcmp();
int cmakeRequireSymbol(int n, ...) { return n; }
int main()
{
  return cmakeRequireSymbol(0, &memcmp);
}

With this version the real signature of the function does not matter but it still requires the function to exist. By making the return value depend on the code it guarantees that the code requiring the symbol will not be optimized away.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0005178)
Brad King (manager)
2006-10-04 14:41

CHECK_FUNCTION_EXISTS is now deprecated anyway for reasons like this. CHECK_SYMBOL_EXISTS and other variants handle it.

 Issue History
Date Modified Username Field Change


Copyright © 2000 - 2018 MantisBT Team