public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14156] New: no warning for address of parameter
@ 2004-02-16  9:56 d dot binderman at virgin dot net
  2004-02-16 12:17 ` [Bug c++/14156] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: d dot binderman at virgin dot net @ 2004-02-16  9:56 UTC (permalink / raw)
  To: gcc-bugs

// Given the following C++ source code

int * f( int a)
{
	return &a;
}

int * g()
{
	int b = 0;

	return &b;
}

/*
then

[dcb@localhost src]$ ~/gnu/gcc333pre2/results/bin/g++ -c -g -O2 -Wall -ansi
-pedantic addrLocal.cc
addrLocal.cc: In function `int* g()':
addrLocal.cc:9: warning: address of local variable `b' returned
[dcb@localhost src]$

Note only one warning message.  
G++ 333 pre release version 2 doesn't find the problem in function f.  
G++ 332 also doesn't find the problem.

Here is Intel C++ doing what I want.

[dcb@localhost src]$ icc -c addrLocal.cc
addrLocal.cc(6): warning #1251: returning pointer to local variable
        return &a;
               ^

addrLocal.cc(13): warning #1251: returning pointer to local variable
        return &b;
               ^

This bug report boiled down from real code in Fedora Core 1.

*/

-- 
           Summary: no warning for address of parameter
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot binderman at virgin dot net
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: linux / x86


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14156


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

end of thread, other threads:[~2004-03-11  5:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-16  9:56 [Bug c++/14156] New: no warning for address of parameter d dot binderman at virgin dot net
2004-02-16 12:17 ` [Bug c++/14156] " pinskia at gcc dot gnu dot org
2004-02-16 12:36 ` pinskia at gcc dot gnu dot org
2004-02-16 13:18 ` pinskia at gcc dot gnu dot org
2004-02-23 15:22 ` cvs-commit at gcc dot gnu dot org
2004-02-23 15:27 ` cvs-commit at gcc dot gnu dot org
2004-02-23 15:29 ` pinskia at gcc dot gnu dot org
2004-02-23 21:00 ` d dot binderman at virgin dot net
2004-02-23 21:36 ` pinskia at gcc dot gnu dot org
2004-02-23 22:41 ` bangerth at dealii dot org
2004-03-11  5:45 ` pinskia 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).