[Bug c/32449] New: declaring Âstrcmp() as an extern function with inclusion of Âstring.h is causing compilation error
suma dot sharma at kpitcummins dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 21 07:58:00 GMT 2007
Hi,
I have successfully built SH4-Linux toolchain based on
(binutils-2.17, gcc-4.2-20061205, glibc-2.5) for Renesas SH target.
I am facing problems while compiling the following testcase-
------------------------------------------------------------------
TESTCASE
#include<string.h>
#include<stdio.h>
extern int strcmp(const char *,const char *);
int main()
{
char s1[3];
char s2[3];
strcpy(s1,"12");
strcpy(s2,"2");
printf("\n\t %d",strcmp(s1,s2));
return 0;
}
-------------------------------------------------------------------------
PROBLEM
The above testcase gets compiled with '-O0' optimization successfully----
Â
/sh4-linux-gcc testcase.c Âo a.out ÂO0
but on compilation with '-O2' optimization option------
Â
/sh4-linux-gcc testcase.c Âo a.out ÂO2
it gives the following
error:-
testcase.c:4: error: expected identifier or Â(Â before Â__extension__Â
testcase.c:4: error: expected identifier or Â(Â before Â)Â token
OBSERVATIONS
1. In the above testcase, declaring Âstrcmp()Â as an extern function with
inclusion of Âstring.h is causing the above mentioned compilation error. But
on the other hand, if either of the two scenarios is used i.e. either
Âstring.h is included or Âstrcmp() is declared as an extern function only,
then it compiles successfully with ÂO2 option.
2. This problem has been observed with
sh-linux toolchain (gcc-4.2)
i686-pc-linux toolchain (gcc-4.1.1, Fedora Core 6)
i686-pc-linux toolchain (gcc-4.2.0)
Any help on this will be appreciated.
Regards,
Suma Sharma
KPIT Cummins Infosystems Ltd,
Pune (INDIA)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based SH-Linux toolchains for Renesas' SH Series.
The following site also offers free technical support to its users.
Visit http://www.kpitgnutools.com for details.
Latest versions of KPIT GNU SH-Linux tools were released on April 5, 2007.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
Summary: declaring Âstrcmp()Â as an extern function with
inclusion of Âstring.h is causing compilation error
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: suma dot sharma at kpitcummins dot com
GCC build triplet: i686-pc-linux
GCC host triplet: sh4-unknown-linux
GCC target triplet: sh4-unknown-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32449
More information about the Gcc-bugs
mailing list