Bug 65550 - gcc 2.96-110 does not perform implicit cast
Summary: gcc 2.96-110 does not perform implicit cast
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.3
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2002-05-27 14:30 UTC by Peter Klotz
Modified: 2007-04-18 16:42 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2002-05-27 18:12:15 UTC

Attachments (Terms of Use)

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)

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:

Steps to Reproduce:
1.gcc cast.c

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;
    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.

Note You need to log in before you can comment on or make changes to this bug.