This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/4681] New: declaring “strcmp()” as an extern function with inclusion of “string.h” is causing compilation error


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: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P3
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: suma dot sharma at kpitcummins dot com
                CC: glibc-bugs at sources dot redhat dot com,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://sourceware.org/bugzilla/show_bug.cgi?id=4681

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]