public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/26533]  New: error: invalid use of void expression
@ 2006-03-02 20:59 kminola at eng dot umd dot edu
  2006-03-02 21:14 ` [Bug c/26533] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: kminola at eng dot umd dot edu @ 2006-03-02 20:59 UTC (permalink / raw)
  To: gcc-bugs

This is probably pretty dodgy C code, but I
find it strange that program foo.c compiles
while program bar.c gives an error.  Is this
a bug?

----------- foo.c --------------
#include <stdio.h>

int main()

{
  int ii;

  ii = 276;
  void *vv = (void *)&ii;
}
----------- foo.c --------------

----------- bar.c --------------
#include <stdio.h>

int main()

{
  int ii;
  void *vv;

  ii = 276;
  *vv = (void *)&ii;
}
----------- bar.c --------------

% gcc -o foo foo.c
% gcc -o bar bar.c
bar.c: In function ESC)B?main?:
bar.c:10: warning: dereferencing ESC)B?void *? pointer
bar.c:10: error: invalid use of void expression
%

For completeness on this report, this was on

% gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /usr/local/gcc-4.0.2/src/gcc-4.0.2/configure
--enable-languages=c --prefix=/usr/local/gcc-4.0.2/x86-Linux
Thread model: posix
gcc version 4.0.2
%


-- 
           Summary: error: invalid use of void expression
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kminola at eng dot umd dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26533


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/26533] error: invalid use of void expression
  2006-03-02 20:59 [Bug c/26533] New: error: invalid use of void expression kminola at eng dot umd dot edu
@ 2006-03-02 21:14 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-02 21:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-03-02 21:14 -------
The first one is ok C even though it is not OK C89 but it is fine C99.
The second one is not ok C at all, since you are deferencing a void pointer.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26533


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-02 21:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-02 20:59 [Bug c/26533] New: error: invalid use of void expression kminola at eng dot umd dot edu
2006-03-02 21:14 ` [Bug c/26533] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).