public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26671] New: Missing "warning: reference to local variable returned"
@ 2006-03-14 0:00 carolh at sinavigator dot com
2006-03-14 0:10 ` [Bug c++/26671] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: carolh at sinavigator dot com @ 2006-03-14 0:00 UTC (permalink / raw)
To: gcc-bugs
class test
{
public:
int secondMember;
};
class test2
{
public:
int requiredForTest;
int secondMember;
};
int &
returnRefToLocalOK()
{
test local;
return local.secondMember;
}
int &
returnRefToLocalMissing()
{
test2 local;
return local.secondMember;
}
int
main()
{
return returnRefToLocalOK();
return returnRefToLocalMissing();
}
===========
gcc fails to generate the warning "reference to local variable returned" for
function returnRefToLocalMissing().
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/specs
Configured with: ../configure
Thread model: posix
gcc version 3.3.6
the command line and resulting output:
gcc test.cc
test.cc: In function `int& returnRefToLocalOK()':
test.cc:16: warning: reference to local variable `local' returned
the preprocessed file:
# 1 "test.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.cc"
class test
{
public:
int secondMember;
};
class test2
{
public:
int requiredForTest;
int secondMember;
};
int &
returnRefToLocalOK()
{
test local;
return local.secondMember;
}
int &
returnRefToLocalMissing()
{
test2 local;
return local.secondMember;
}
int
main()
{
return returnRefToLocalOK();
return returnRefToLocalMissing();
}
Also occurs in gcc versions 3.3.3 through 3.3.5.
--
Summary: Missing "warning: reference to local variable returned"
Product: gcc
Version: 3.3.6
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: carolh at sinavigator dot com
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1/4.2 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
@ 2006-03-14 0:10 ` pinskia at gcc dot gnu dot org
2006-06-04 18:05 ` mmitchel at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-14 0:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-03-14 00:10 -------
It is even worse in 4.0.0 and above where we don't warn at all, I will look
into this later this week.
I am going to mark this as a regression for 4.0 because I think my fix will
also fix both reference to local variable problem.
Oh and the C front-end is not affected.
Related to the old PR 14156.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Known to fail| |4.0.0 4.1.0 4.2.0
Last reconfirmed|0000-00-00 00:00:00 |2006-03-14 00:10:44
date| |
Summary|Missing "warning: reference |[4.0/4.1/4.2 Regression]
|to local variable returned" |Missing "warning: reference
| |to local variable returned"
Target Milestone|--- |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1/4.2 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
2006-03-14 0:10 ` [Bug c++/26671] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-06-04 18:05 ` mmitchel at gcc dot gnu dot org
2006-06-28 9:52 ` pluto at agmk dot net
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 18:05 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1/4.2 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
2006-03-14 0:10 ` [Bug c++/26671] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-06-04 18:05 ` mmitchel at gcc dot gnu dot org
@ 2006-06-28 9:52 ` pluto at agmk dot net
2006-07-05 18:19 ` jason at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pluto at agmk dot net @ 2006-06-28 9:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pluto at agmk dot net 2006-06-28 08:56 -------
following testcase doesn't generate warning in 4.1.2svn.
3.3.6 works fine.
#include <string>
std::string const& foo()
{
std::string tab[ 1 ] = { std::string( "text" ) };
int const idx = 0;
return tab[ idx ];
}
--
pluto at agmk dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pluto at agmk dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1/4.2 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
` (2 preceding siblings ...)
2006-06-28 9:52 ` pluto at agmk dot net
@ 2006-07-05 18:19 ` jason at gcc dot gnu dot org
2006-09-06 0:24 ` jason at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-07-05 18:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jason at gcc dot gnu dot org 2006-07-05 18:19 -------
added known to work in 3.3.6
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |3.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1/4.2 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
` (3 preceding siblings ...)
2006-07-05 18:19 ` jason at gcc dot gnu dot org
@ 2006-09-06 0:24 ` jason at gcc dot gnu dot org
2006-09-06 5:25 ` jason at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-09-06 0:24 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2006-03-14 00:10:44 |2006-09-06 00:23:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1/4.2 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
` (4 preceding siblings ...)
2006-09-06 0:24 ` jason at gcc dot gnu dot org
@ 2006-09-06 5:25 ` jason at gcc dot gnu dot org
2006-09-07 22:27 ` [Bug c++/26671] [4.0/4.1 " jason at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-09-06 5:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jason at gcc dot gnu dot org 2006-09-06 05:25 -------
Subject: Bug 26671
Author: jason
Date: Wed Sep 6 05:25:29 2006
New Revision: 116714
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116714
Log:
PR c++/26671
* typeck.c (maybe_warn_about_returning_address_of_local): Look
through COMPONENT_REF and ARRAY_REF.
Added:
trunk/gcc/testsuite/g++.dg/warn/return-reference2.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
` (5 preceding siblings ...)
2006-09-06 5:25 ` jason at gcc dot gnu dot org
@ 2006-09-07 22:27 ` jason at gcc dot gnu dot org
2006-09-07 22:38 ` jason at gcc dot gnu dot org
2006-09-07 23:05 ` jason at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-09-07 22:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2006-09-07 22:27 -------
Subject: Bug 26671
Author: jason
Date: Thu Sep 7 22:27:01 2006
New Revision: 116763
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116763
Log:
PR c++/26195
* decl.c (make_rtl_for_nonlocal_decl),
(start_preparsed_function): Don't use lbasename on
input_filename when calling get_fileinfo.
* semantics.c (begin_class_definition): Likewise.
* lex.c (cxx_make_type): Likewise.
(handle_pragma_interface): Call get_fileinfo on input_filename,
not on the parameter to the directive.
PR c++/26696
* cvt.c (convert_to_void): Replace a subexpression with no side
effects with void_zero_node.
* tree.c (is_overloaded_fn): Look through COMPONENT_REF.
(get_first_fn): Ditto.
* decl.c (grokdeclarator): No need to look through COMPONENT_REF.
PR c++/26571
* parser.c (cp_parser_diagnose_invalid_type_name): Handle the case
where the name is a type used incorrectly.
PR c++/26671
* typeck.c (maybe_warn_about_returning_address_of_local): Look
through COMPONENT_REF and ARRAY_REF.
PR c++/26102
* name-lookup.c (do_class_using_decl): Try to find the base even
if bases_dependent_p.
* pt.c (type_dependent_expression_p): A USING_DECL is dependent.
PR c++/19809
* pt.c (tsubst_friend_function): Set DECL_INITIAL before pushdecl.
Modified:
branches/gcc-4_1-branch/gcc/cp/ChangeLog
branches/gcc-4_1-branch/gcc/cp/cvt.c
branches/gcc-4_1-branch/gcc/cp/decl.c
branches/gcc-4_1-branch/gcc/cp/lex.c
branches/gcc-4_1-branch/gcc/cp/name-lookup.c
branches/gcc-4_1-branch/gcc/cp/parser.c
branches/gcc-4_1-branch/gcc/cp/pt.c
branches/gcc-4_1-branch/gcc/cp/semantics.c
branches/gcc-4_1-branch/gcc/cp/tree.c
branches/gcc-4_1-branch/gcc/cp/typeck.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
` (6 preceding siblings ...)
2006-09-07 22:27 ` [Bug c++/26671] [4.0/4.1 " jason at gcc dot gnu dot org
@ 2006-09-07 22:38 ` jason at gcc dot gnu dot org
2006-09-07 23:05 ` jason at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-09-07 22:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jason at gcc dot gnu dot org 2006-09-07 22:38 -------
Subject: Bug 26671
Author: jason
Date: Thu Sep 7 22:38:03 2006
New Revision: 116764
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116764
Log:
PR c++/26195
* decl.c (make_rtl_for_nonlocal_decl),
(start_preparsed_function): Don't use lbasename on
input_filename when calling get_fileinfo.
* semantics.c (begin_class_definition): Likewise.
* lex.c (cxx_make_type): Likewise.
(handle_pragma_interface): Call get_fileinfo on input_filename,
not on the parameter to the directive.
PR c++/26696
* cvt.c (convert_to_void): Replace a subexpression with no side
effects with void_zero_node.
* tree.c (is_overloaded_fn): Look through COMPONENT_REF.
(get_first_fn): Ditto.
* decl.c (grokdeclarator): No need to look through COMPONENT_REF.
PR c++/26571
* parser.c (cp_parser_diagnose_invalid_type_name): Handle the case
where the name is a type used incorrectly.
PR c++/26671
* typeck.c (maybe_warn_about_returning_address_of_local): Look
through COMPONENT_REF and ARRAY_REF.
PR c++/19809
* pt.c (tsubst_friend_function): Set DECL_INITIAL before pushdecl.
Modified:
branches/gcc-4_0-branch/gcc/cp/ChangeLog
branches/gcc-4_0-branch/gcc/cp/cvt.c
branches/gcc-4_0-branch/gcc/cp/decl.c
branches/gcc-4_0-branch/gcc/cp/lex.c
branches/gcc-4_0-branch/gcc/cp/parser.c
branches/gcc-4_0-branch/gcc/cp/pt.c
branches/gcc-4_0-branch/gcc/cp/semantics.c
branches/gcc-4_0-branch/gcc/cp/tree.c
branches/gcc-4_0-branch/gcc/cp/typeck.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/26671] [4.0/4.1 Regression] Missing "warning: reference to local variable returned"
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
` (7 preceding siblings ...)
2006-09-07 22:38 ` jason at gcc dot gnu dot org
@ 2006-09-07 23:05 ` jason at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-09-07 23:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jason at gcc dot gnu dot org 2006-09-07 23:05 -------
Fixed
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26671
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-09-07 23:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-14 0:00 [Bug c++/26671] New: Missing "warning: reference to local variable returned" carolh at sinavigator dot com
2006-03-14 0:10 ` [Bug c++/26671] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-06-04 18:05 ` mmitchel at gcc dot gnu dot org
2006-06-28 9:52 ` pluto at agmk dot net
2006-07-05 18:19 ` jason at gcc dot gnu dot org
2006-09-06 0:24 ` jason at gcc dot gnu dot org
2006-09-06 5:25 ` jason at gcc dot gnu dot org
2006-09-07 22:27 ` [Bug c++/26671] [4.0/4.1 " jason at gcc dot gnu dot org
2006-09-07 22:38 ` jason at gcc dot gnu dot org
2006-09-07 23:05 ` jason at gcc dot gnu dot 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).