public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/18740] New: Execution-time sizeof drops side effects
@ 2004-11-30 16:38 terra at gnome dot org
  2004-11-30 17:09 ` [Bug c/18740] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: terra at gnome dot org @ 2004-11-30 16:38 UTC (permalink / raw)
  To: gcc-bugs

The program below, which is a slight variation of a program from C99
section 6.5.3.4, contains an execution-time sizeof operator and its
argument should thus be evaluated.  Nevertheless, "i" in not incremented.

I would expect "i=1" to be printed.  I get "i=0".

(Sun's C compiler seems to do the same thing.)



#include <stdio.h>

size_t fsize3 (int n)
{
  int i = 0;
  char b[1][n+3];       // Variable length array.
  size_t s = sizeof (b[i++]);    // Execution time sizeof.
  printf ("i=%d\n", i);
  return s;
}

int main()
{
  size_t size;
  size = fsize3(10);
  return 0;
}

-- 
           Summary: Execution-time sizeof drops side effects
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terra at gnome dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8


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


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

end of thread, other threads:[~2006-06-04 17:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-18740-9033@http.gcc.gnu.org/bugzilla/>
2006-05-09  0:47 ` [Bug c/18740] Execution-time sizeof drops side effects mrs at apple dot com
2006-05-18 18:22 ` mrs at gcc dot gnu dot org
2006-06-04 17:01 ` jsm28 at gcc dot gnu dot org
2004-11-30 16:38 [Bug c/18740] New: " terra at gnome dot org
2004-11-30 17:09 ` [Bug c/18740] " pinskia at gcc dot gnu dot org
2004-11-30 22:24 ` bangerth at dealii dot org
2004-11-30 22:48 ` bangerth at dealii dot org
2004-12-01  1:44 ` jsm28 at gcc dot gnu dot org
2004-12-21 11:16 ` ebotcazou at gcc dot gnu dot org
2004-12-21 13:39 ` rth at gcc dot gnu dot org
2004-12-21 13:43 ` rth at gcc dot gnu dot org
2005-02-12 22:35 ` 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).