[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: bug in gcc?
- From: Sam Roberts <sroberts@...>
- Date: Wed, 4 Apr 2007 11:52:41 -0700
On Wed, Apr 04, 2007 at 03:25:56PM -0300, Roberto Ierusalimschy wrote:
> > The literal 0 (and NULL, which is defined to be 0) is explicitly
> > comparable and assignable to a pointer, even in C++ (test1.cc), so I
> > don't think its correct to say 0 is of type int.
> > Unlike 0, the result of a comma expression has a type, int in this
> > case, and int cannot be assigned to a pointer in C++, or without
> > warnings in C (test2.cc), not sure if its a bug. Of course, test3.cc
> > is plainly not legal.
> That makes sense. What surprised me is that the construction does not
> generate even a warning in C.
I guess it depends on the gcc version:
% gcc -c test2.c
test2.c: In function ‘func’:
test2.c:3: warning: return makes pointer from integer without a cast
const char *func()
return 0, 0;
% gcc --version
gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)