http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59267
Bug ID: 59267 Summary: gcc 4.8.2 optimizes code with side-effects away Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: troomps01 at gmail dot com Created attachment 31285 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31285&action=edit A very simple C++ program and Makefile that compiles without warning, but also optimizes out some necessary code. G++ version: g++ (GCC) 4.8.2 20131017 (Red Hat 4.8.2-1) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. OS: Linux Distro: Fedora 19 Here's the fun: I don't have any optimization turned on in the compile line. What the attached zip contains: main.cpp -- A simple C++ program that shows how stringstreams are optimized out during compilation Makefile -- A makefile that has all of the flags I am using in another project where I originally encountered the problem. It is worth noting, that even if you don't have _any_ of the flags I provided in the Makefile, the code is still optimized away. In fact, you could reduce the Makefile to this "g++ -o main main.cpp" and the problem persists.