This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: optimization/5159: ptr[i] = ptr[++i]; // works differently with malloc() and -O


Synopsis: ptr[i] = ptr[++i]; // works differently with malloc() and -O

State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Tue Dec 18 15:22:36 2001
State-Changed-Why:
    Not a bug - you should read up on sequence points.  Basically, multiple reads of a variable (i) modified between sequence points is undefined.  Your code falls into this category.  So,
    
    ptr[i] = ptr[++i];
    
    is fundamentally always meaningless.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5159


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]