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

stpncpy broken on OS X with icc version 12.1.5

Marc_Lavergne
Beginner
357 Views
Given the following test case on OS X:
#include
#include
int main(int argc, const char * argv[]) 
{
  char data1[8] = "foo";
  char data2[16] = "helloworld";
  
  // links and works
  // char* ptr = stpcpy(data1, data1); 
  // links and works
  // char* ptr = strncpy(data1, data2, sizeof(data1));
  
  // doesn't link (Undefined symbols for architecture x86_64)
  char* ptr = stpncpy(data1, data2, sizeof(data1));
  
  printf("%s\\n", data1);
  return 0;
}
I get the following:
# icc main.c 
main.c(16): warning #42: operand types are incompatible ("int" and "char *")
    char* ptr = stpncpy(data1, data2, sizeof(data1));
                ^
Undefined symbols for architecture x86_64:
  "___builtin___stpncpy_chk", referenced from:
      _main in icczDRt9N.o
ld: symbol(s) not found for architecture x86_64
The same code works fine under ICC for Linux. Since stpncpy is a part of libc, I'm assuming that this is a known bug in ICC for OS X? 
0 Kudos
1 Reply
Jeffrey_A_Intel
Employee
357 Views
FWIW, I don't see any errors when compiling with

Intel® C Intel® 64 Compiler XE for applications running on Intel® 64, Version 12.1.6.367 Build 20120612

or

Intel® C Intel® 64 Compiler XE for applications running on Intel® 64, Version 13.0.0.088 Build 20120731

on Mac OS 10.8.  The command line was simply "icc test.cpp"

Both produce

hellowor??

when I run the resulting a.out.
0 Kudos
Reply