This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12667] [3.3 regression] max(enum) returns reference to temporary
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Nov 2003 17:47:29 -0000
- Subject: [Bug c++/12667] [3.3 regression] max(enum) returns reference to temporary
- References: <20031017235414.12667.mdorey@bluearc.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2003-11-16 17:47 -------
The code in comment #3 is definitely wrong. You call
max(E1,E2)
both E1 and E2 are names that when evaluated yield temporary variables. These
temporaries are then bound to the constant references in the args to max, and
you return a reference to a temporary from that function. The lifetime of the temporary
ends at the end of the call expression, so you get garbage when using the result int
the call to operator<<
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12667