Red Hat Bugzilla – Bug 131419
wcswcs returns invalid address
Last modified: 2007-11-30 17:07:03 EST
Description of problem:
wchar_t *wcswcs(wchar_t *, wchar_t *) does not return valid address.
Version-Release number of selected component (if applicable):
Architecture used is Itanium 2.
Please find the test case attached to this bug report.
Steps to Reproduce:
1. Compile the C test case using:
2. Run the executable a.out
Segmentation fault (core dumped)
The same test case works on i686 and fails on ia64
Created attachment 103331 [details]
This is a C program to reproduce the problem
It always help to compile with warnings enabled.
gcc -Wall test.c
test.c: In function `main':
test.c:13: warning: implicit declaration of function `mbstowcs'
test.c:17: warning: implicit declaration of function `wcswcs'
test.c:17: warning: assignment makes pointer from integer without a cast
test.c:31: warning: implicit declaration of function `wcstombs'
test.c:32: warning: implicit declaration of function `strlen'
test.c:33: warning: int format, different type arg (arg 2)
makes it clear that you are missing some includes
) and also, given that wcswcs is a X/Open only function (ISO C99
uses wcsstr), you need to enable X/Open feature set, see info libc
on Feature Set Macros.
I.e. if you add those two includes and compile with -D_XOPEN_SOURCE,
-D_GNU_SOURCE, -D_XOPEN_SOURCE=600 or similar, it will work just fine.
Unprototyped functions are assumed to return int, so really bad things
happen on 64-bit arches for functions which return pointers or other
64-bit values or on all arches if they return floating point values
and prototypes aren't used.