public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16309] New: different behavior in lvalue assignment in -O0 & -O2
@ 2004-07-01  8:49 nakkore at libero dot it
  2004-07-01  9:08 ` [Bug c/16309] " falk at debian dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nakkore at libero dot it @ 2004-07-01  8:49 UTC (permalink / raw)
  To: gcc-bugs

Compiling with -O2 and -O0 the following code i obtain different
result with gcc version > 3.2 ( i tryed 3.3.3,3.3.4)

unsigned char dest[10],source[10]={1,2,3,4,5,6,7,8,9,10};

int main(void)
{
  int i = 1;
  int step = 1;

  while (i < 8)
    dest[i] = source[(i++*step) % 7];


  for(i=0; i < 8; i++)
    printf("%02x ",dest[i]);

  printf("\n");


  i=1;

  while (i < 8)
    {
      dest[i] = source[(i*step) % 7];
      i++;
    }

  for(i=0; i < 8; i++)
    printf("%02x ",dest[i]);

  printf("\n");

  return(i+dest[6]);
}

the difference is how dest[i] is addressed via the index i.

-- 
           Summary: different behavior in lvalue assignment in -O0 & -O2
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nakkore at libero dot it
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: Reading specs from /usr/lib/gcc-lib/i686-pc-linux-
                    gnu/3.3.3/spec
  GCC host triplet: i386
GCC target triplet: i386


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


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

* [Bug c/16309] different behavior in lvalue assignment in -O0 & -O2
  2004-07-01  8:49 [Bug c/16309] New: different behavior in lvalue assignment in -O0 & -O2 nakkore at libero dot it
@ 2004-07-01  9:08 ` falk at debian dot org
  2004-08-13 16:01 ` bangerth at dealii dot org
  2004-08-13 16:05 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: falk at debian dot org @ 2004-07-01  9:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2004-07-01 09:08 -------
With -Wall, you get:

test.c:9: warning: operation on `i' may be undefined

and in fact it is; see documentation on -Wsequence-point.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID
            Summary|different behavior in lvalue|different behavior in lvalue
                   |assignment in -O0 & -O2     |assignment in -O0 & -O2


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


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

* [Bug c/16309] different behavior in lvalue assignment in -O0 & -O2
  2004-07-01  8:49 [Bug c/16309] New: different behavior in lvalue assignment in -O0 & -O2 nakkore at libero dot it
  2004-07-01  9:08 ` [Bug c/16309] " falk at debian dot org
@ 2004-08-13 16:01 ` bangerth at dealii dot org
  2004-08-13 16:05 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-08-13 16:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-13 16:01 -------
Reopening to mark as a duplicate of... 

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


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


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

* [Bug c/16309] different behavior in lvalue assignment in -O0 & -O2
  2004-07-01  8:49 [Bug c/16309] New: different behavior in lvalue assignment in -O0 & -O2 nakkore at libero dot it
  2004-07-01  9:08 ` [Bug c/16309] " falk at debian dot org
  2004-08-13 16:01 ` bangerth at dealii dot org
@ 2004-08-13 16:05 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-08-13 16:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-13 16:04 -------
...PR 11751. 

*** This bug has been marked as a duplicate of 11751 ***

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


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


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

end of thread, other threads:[~2004-08-13 16:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-01  8:49 [Bug c/16309] New: different behavior in lvalue assignment in -O0 & -O2 nakkore at libero dot it
2004-07-01  9:08 ` [Bug c/16309] " falk at debian dot org
2004-08-13 16:01 ` bangerth at dealii dot org
2004-08-13 16:05 ` bangerth at dealii 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).