public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jbakker@rssd.esa.int
To: gcc-gnats@gcc.gnu.org
Cc: ulammers@rssd.esa.int
Subject: c++/9769: compiles wrong code but executable SEGV with -freg-struct-return
Date: Thu, 20 Feb 2003 10:06:00 -0000	[thread overview]
Message-ID: <20030220095942.28218.qmail@sources.redhat.com> (raw)


>Number:         9769
>Category:       c++
>Synopsis:       compiles wrong code but executable SEGV with -freg-struct-return
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 20 10:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jorgo Bakker
>Release:        gcc version 3.2.2
>Organization:
>Environment:
Reading specs from /usr/local/devel/gcc-3.2.2/lib/gcc-lib/sparc-sun-solaris2.8/3.2.2/specs
Configured with: ../gcc-3.2.2/configure --prefix=/usr/local/devel/gcc-3.2.2 --with-gnu-as --with-as=/usr/local/bin/as --with-gnu-ld --with-ld=/usr/local/bin/ld --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.2.2
>Description:
Compiling (wrong? operator+(const char*, std::string) ) code, make sthe resulting executable seg.fault, if
the "-freg-struct-return" is given without optimization.

With optimization (-O2), things work.


>How-To-Repeat:
$ cat > bug.cc
// -*-C++-*-
// File:      bug.cc
// Author:    Jorgo Bakker (jbakker@rssd.esa.int)
// Generated: Thu Feb 20 09:53:50 MET 2003
#include<string>
#include<iostream>

int main() {
  std::string s("This is my life");
  std::cout << "*** " << s << std::endl; // ok
  std::cout << "*** " + s << std::endl; // seg fault
  return 0;
}  
^D
$c++ -freg-struct-return bug.cc -o bug
$./bug
*** This is my life
Abort (core dumped)

>Fix:
- Compiler should bail out on: "*** " + s
or
- Behavior should be the same with/without -freg-struct-return
>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2003-02-20 10:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030220095942.28218.qmail@sources.redhat.com \
    --to=jbakker@rssd.esa.int \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=ulammers@rssd.esa.int \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).