Bug 65550

Summary: gcc 2.96-110 does not perform implicit cast
Product: [Retired] Red Hat Linux Reporter: Peter Klotz <peter.klotz99>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WORKSFORME QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-05-27 18:12:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Peter Klotz 2002-05-27 14:30:23 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc2)
Gecko/20020510

Description of problem:
gcc 2.96-110 refuses to perform the implicit cast from void* to int* in C mode.
gcc 2.96-98, gcc 3.1, gcc 2.95.3, MSVC 6 and Comeau 4.3 compile the code. 
gcc 2.96-98 compiles the ORB MICO (www.mico.org), gcc 2.96-110 does not because
a code fragment similar to this one shows up in C code generated by Bison.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.gcc cast.c
2.
3.
	

Actual Results:  cast.c: In function `int main ()':
cast.c:6: cannot convert `void *' to `int *' for argument `1' to `f
(int *)'


Expected Results:  Should compile.

Additional info:

void f(int* i) {}

int main(void)
{
    void* v=0;
    f(v);
    return 0;
}

Comment 1 Jakub Jelinek 2002-05-27 17:08:01 UTC
Works for me just fine:
gcc -W -Wall n.c
n.c: In function `f':
n.c:1: warning: unused parameter `i'
gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-110)

My guess is you used the g++ driver, in that case you really get that error:

g++ -W -Wall n.c
n.c: In function `void f (int *)':
n.c:1: warning: unused parameter `int *i'
n.c: In function `int main ()':
n.c:6: cannot convert `void *' to `int *' for argument `1' to `f (int *)'

but that's correct, C++ doesn't allow this and running g++ on a .c file
compiles it as C++.

You get similar error from gcc 3.1:

g++3 -W -Wall n.c
n.c: In function `void f(int*)':
n.c:1: warning: unused parameter `int*i'
n.c: In function `int main()':
n.c:6: invalid conversion from `void*' to `int*'
g++3 -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.1/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib
Thread model: posix
gcc version 3.1 20020525 (Red Hat Linux 7.3 3.1-3)

Comment 2 Peter Klotz 2002-05-27 18:12:10 UTC
You are absolutely right. For some reason /usr/bin/gcc was a softlink to
/usr/bin/g++. After restoring gcc via rpm it worked.

Sorry for the false bug report.