Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Mac OS X standard library problems

bobclark
Beginner
379 Views

I'm starting to use the Intel C++ compiler in a project that has until now used gcc. (I'm using Xcode 2.4. and icc 9.1.029.)

I'm building a plugin usingicc that will plug in to an application built using gcc. I don't know whether that makes a difference.

I'm seeing some crashes in memset and memcpy. Has anyone heard of problems using Intel's (statically-linked) standard C library? And is there an easy workaround?

Just for kicks I replaced the memset call with a bzero (it was memsetting to zero) and surprise! that crash went away. But before I start replacing all standard library functions I figured I'd ask around to see whether this is a known issue.

--Bob

0 Kudos
3 Replies
Dale_S_Intel
Employee
379 Views

I'm not aware of any general problems with these. Of course, if you give it bad parameters it will crash in those functions, which would not indicate a problem in the libs. But it sounds like you've confirmed that at least your memset should work.

Can you provide a reproducible test case? I'd be really interested in seeing it, in case there is some problem that needs fixing.

Thanks!

Dale

0 Kudos
bobclark
Beginner
379 Views
I've been trying to concoct a small repro case, and haven't been successful so far. I know (believe me!) how much harder that makes it to diagnose.

Assuming pSrc and pDst are valid pointers, the code looks something like this:

size_t memcpylen = foo; // foo == 26
memcpy(pDst, pSrc, memcpylen);

and this is failing to do anything. (i.e. it leaves the memory at pDst untouched.)

If I use this code instead:

memcpy(pDst, pSrc, 26);

it works.

In other words, I'm seeing memcpy fail when the length parameter is a variable and succeed when the length parameter is a constant.

In attempted (simplified!) repro cases (where all the code is compiled with icc) I can NOT repro this failure. This failure only occurs in an environment where the application has been compiled using gcc and the plugin I'm working on has been compiled with icc.

0 Kudos
bobclark
Beginner
379 Views
Sorry, I clicked Post in the wrong tab.

More information: the reason that it works when I pass a constant in to memcpy is that it inlines a memcpy. When I pass in a variable it actually does generate a call to intel_fast_memcpy.

And more: in my "simplified" test case I cannot get icc to generate a call to intel_fast_memcpy: even when I set the all the icc-related parameters in Xcode to equal my problem case, my "simplified" test case insists on generating a call to memcpy. It seems that only when intel_fast_memcpy is used do I see the problem.
0 Kudos
Reply