[Bug c++/57937] New: fgets and cout tricky bug

2013-07-19 Thread linkerpro at mail dot ru
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57937

Bug ID: 57937
   Summary: fgets and cout tricky bug
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: linkerpro at mail dot ru

Created attachment 30529
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30529&action=edit
code demostrating the bug

Hi

It's seem I have found very tricky bug while trying to resolve MAC addr by IP
in my local network.

Requerement: to use see the bug - at line 50 of attachment you should put a
real host in your local network, and this host must be present in arp table. In
my case 192.168.1.1 is my gateway. 

compiles OK without any warning
$ g++ bug.cpp --std=c++0x -Wall -Wextra

run (no output) 
$ ./a.out 

$ 

Next uncomment line 36 of attachment (simple debug cout) !

recompile OK
$ g++ bug.cpp --std=c++0x -Wall -Wextra

run OK
$ ./a.out
> 192.168.1.1
00:01:02:03:04:05


So if I put any cout in for loop - everything is OK.



Ubuntu 12.10 with latest updates.

$ uname -a
Linux notebook 3.5.0-36-generic #57-Ubuntu SMP Wed Jun 19 15:10:49 UTC 2013
x86_64 x86_64 x86_64 GNU/Linux


[Bug c++/57937] fgets and cout tricky bug

2013-07-19 Thread linkerpro at mail dot ru
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57937

Alexei Semenoff  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
  Component|libstdc++   |c++
 Resolution|INVALID |---

--- Comment #2 from Alexei Semenoff  ---
Why example above works with simple cout ?
How cout is related with returning local or non local variable ?