[Bug c++/57693] New: The program logically failed in case of used int b += b++

2013-06-24 Thread vlad94009277 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57693

Bug ID: 57693
   Summary: The program logically failed in case of used int b +=
b++
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vlad94009277 at gmail dot com

Steps to reproduce:

1. Write the following source cod and compile it:

#include iostream
using namespace std;

int main(){
int d = 7;
int c = 7;
int b = c;
b += b++;
d += d++;
cout  c =  c  endl;
cout  d =  d  endl;
return 0;
}

2. Run the appropriate generated executable file.

Actual result: 
It's printed:
c = 8
d = 15

Expected result:
It should be printed:
c = 15
d = 15

Please note that there are different assemble codes for used operators:

1) d += d++
movl -4(%rbp), %eax // Copies value of d to register %eax
addl %eax, %eax // Adds %eax to %eax, remembers the value in %eax
movl %eax, -4(%rbp) // Moves %eax to d (d = 14)
addl $1, -4(%rbp) // Increments the value of d (d = 15)

2) b += b++

movl -12(%rbp), %eax // Moves the value of b to %eax
movl -12(%rbp), %edx // Moves the value of b to %edx
leal (%rax,%rdx), %edx // Adds %rax to %rdx and stores result in %edx (%rax and
%rdx are equal to 7, so after this operation %edx is 14)
movl %edx, -12(%rbp) // Moves %edx to d (d = 14)
addl $1, %eax // Increments the value of %eax (%eax = 8).
movl %eax, -12(%rbp) // Moves %eax to d (d = 8)


[Bug c++/57693] The program logically failed in case of used int b += b++

2013-06-24 Thread vlad94009277 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57693

--- Comment #2 from Vladimir vlad94009277 at gmail dot com ---
(In reply to Andrew Pinski from comment #1)
 Both:
  b += b++;
 And
 d += d++;
 
 are undefined what value b and d is going to be as there are no sequence
 point intbetween the two assignments.
 
 They could be:
 temp = b;
 b++;
 b += temp;
 
 or b++;
 b+=b;

I tried this issue on version 4.8.1 and it works successfully.
It seems the bug was already fixed.


[Bug c++/57671] New: Compile Error: When declared a pointer const TYPE const *p ; (p is name of pointer)

2013-06-21 Thread vlad94009277 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57671

Bug ID: 57671
   Summary: Compile Error: When  declared a pointer const TYPE
const *p ; (p is name of pointer)
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: blocker
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vlad94009277 at gmail dot com

Compile Error: When declared the pointer const int const *p ;

Actual result:
   error: duplicate ‘const’
   const int const *p ;

expected result: 
   Must be declared the pointer p: