Bug 18677 - [3.4/4.0 regression] ICE: Segmentation fault (program cc1plus)
Summary: [3.4/4.0 regression] ICE: Segmentation fault (program cc1plus)
Status: RESOLVED DUPLICATE of bug 17431
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: 3.4.4
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2004-11-25 21:18 UTC by Debian GCC Maintainers
Modified: 2004-11-26 21:00 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 3.4.3 4.0.0
Last reconfirmed: 2004-11-25 21:55:24


Attachments
preprocessed source (133.94 KB, application/x-gzip)
2004-11-25 21:19 UTC, Debian GCC Maintainers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2004-11-25 21:18:37 UTC
[forwarded from http://bugs.debian.org/282463]

seen on {alpha,i486,x86_64}-linux, with 3.4.3 and HEAD 20041116, ok with 3.3.5

$ g++-4.0 -Wall -DHAVE_CONFIG_H   -c -o grap.o grap.cc 
g++-4.0: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Debian GCC Maintainers 2004-11-25 21:19:26 UTC
Created attachment 7611 [details]
preprocessed source
Comment 2 Andrew Pinski 2004-11-25 21:55:24 UTC
The code is invalid but we should not be seg faulting on it.
Reduced code:
struct string {};
struct DisplayString : public string {
    DisplayString() ;
    DisplayString(char *s);
    DisplayString(string s);
    DisplayString(DisplayString& ds) ;
};
DisplayString a = "%g";
Comment 3 Andrew Pinski 2004-11-25 22:03:04 UTC
: Search converges between 2004-06-27-trunk (#473) and 2004-06-28-trunk (#474).
: Search converges between 2004-06-28-3.4 (#11) and 2004-06-29-3.4 (#12).

With the comeau online C++ compiler I get the following error:
"ComeauTest.c", line 8: error: "DisplayString::DisplayString(DisplayString &)",
          required for copy that was eliminated, is not callable because
          reference parameter cannot be bound to rvalue
  DisplayString a = "%g";
                    ^
which is correct.

and the reason why this is not valid code is because the "copy" construtor requires a lvalue and we 
don't have a lvalue here but a rvalue.
Comment 4 Giovanni Bajo 2004-11-26 00:00:12 UTC
The segfault comes from an infinite recursion which eventually causes a stack 
overflow.

My bets are on:

2004-06-28  Nathan Sidwell  <nathan@codesourcery.com>

        PR c++/16174
        * call.c (build_temp): Declare.
        (check_constructor_callable): New.
        (reference_binding): Only set CHECK_COPY_CONSTRUCTOR if not for
        CONSTRUCTOR_CALLABLE.
        (convert_like_real, initialize_reference): Use
        check_constructor_callable.
        * cp-tree.h (LOOKUP_CONSTRUCTOR_CALLABLE): New.
        (LOOKUP_*): Renumber.

and it's an easy win :)
Comment 5 Volker Reichelt 2004-11-26 21:00:44 UTC

*** This bug has been marked as a duplicate of 17431 ***