public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/64112] New: Optimized away string literal leads to a core dump
@ 2014-11-29  5:15 fhansen at rocketmail dot com
  2014-11-29  5:19 ` [Bug regression/64112] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: fhansen at rocketmail dot com @ 2014-11-29  5:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64112

            Bug ID: 64112
           Summary: Optimized away string literal leads to a core dump
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fhansen at rocketmail dot com

The following program prints "str" when compiled without optimizations but core
dumps when compiled with GCC 4.8.0 and optimization level -O2.

The compilation command used: g++ -O2 test.cpp

#include <cstdio>

class X {
public:
  X(const char* str) : str_(str) {}
  const char* str_;
};

class Y {
public:
  Y(const X& x) : x_(x) {}
  void print() const { printf("%s\n", x_.str_); }

private:
  const X& x_;
};

int main() {
  Y y("str");
  y.print();
}

This appears to be a regression in 4.8.

Version and target:
g++ (GCC) 4.8.0
i686-pc-linux-gnu


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

* [Bug regression/64112] Optimized away string literal leads to a core dump
  2014-11-29  5:15 [Bug regression/64112] New: Optimized away string literal leads to a core dump fhansen at rocketmail dot com
@ 2014-11-29  5:19 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-11-29  5:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64112

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
  Y y("str");


Produces a temporary X which is destroyed after the statement as the life time
is not extended.


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

end of thread, other threads:[~2014-11-29  5:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-29  5:15 [Bug regression/64112] New: Optimized away string literal leads to a core dump fhansen at rocketmail dot com
2014-11-29  5:19 ` [Bug regression/64112] " pinskia at gcc dot gnu.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).