Bug 65550 - gcc 2.96-110 does not perform implicit cast
gcc 2.96-110 does not perform implicit cast
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-05-27 10:30 EDT by Peter Klotz
Modified: 2007-04-18 12:42 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-05-27 14:12:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Peter Klotz 2002-05-27 10:30:23 EDT
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 13:08:01 EDT
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 14:12:10 EDT
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.