public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3827: new int problem.
@ 2001-07-25 17:36 fasbjx, Branjonneau
0 siblings, 0 replies; 3+ messages in thread
From: fasbjx, Branjonneau @ 2001-07-25 17:36 UTC (permalink / raw)
To: gcc-gnats, debian-gcc
>Number: 3827
>Category: c++
>Synopsis: No initialization of an int allocated with new int.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Jul 25 17:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Franck Branjonneau
>Release: 3.0 (Debian) (Debian testing/unstable)
>Organization:
>Environment:
System: Linux alpha.tchume.net 2.4.4 #2 mar mai 22 08:16:07 CEST 2001 i586 unknown
Architecture: i586
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-x --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
I compile the following code:
#include <iostream>
namespace utility {
template< typename T, int role, bool ndebug >
struct init {
static T * do_it() {
T* tmp(new T);
std::cout << "/tmp/ point to: " << *tmp << "\n";
return tmp;
}
};
template< typename T, int role, bool ndebug >
struct exit {
static void do_it(T * instance) { delete instance; }
};
} // namespace utility
int main() {
{
int * tmp(utility::init< int, 1, true >::do_it());
utility::exit< int, 1, true >::do_it(tmp);
}
int * tmp(utility::init< int, 0, true >::do_it());
}
got an executable and call it. The ouput was:
/tmp/ point to: 0
/tmp/ point to: 1075812784
>How-To-Repeat:
It's a context-dependant bug, so I don't know.
As an example, if I comment out utility::exit< int, 1, true >::do_it(tmp) in main(), the behavior is correct.
>Fix:
Customize operator new() ;-)
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/3827: new int problem.
@ 2001-07-26 0:26 Gabriel Dos Reis
0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Dos Reis @ 2001-07-26 0:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/3827; it has been noted by GNATS.
From: Gabriel Dos Reis <gdr@codesourcery.com>
To: fasbjx@free.fr
Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org
Subject: Re: c++/3827: new int problem.
Date: 26 Jul 2001 09:16:52 +0200
fasbjx@libertysurf.fr, Branjonneau@free.fr writes:
| template< typename T, int role, bool ndebug >
| struct init {
| static T * do_it() {
| T* tmp(new T);
| std::cout << "/tmp/ point to: " << *tmp << "\n";
| return tmp;
| }
| };
| /tmp/ point to: 0
| /tmp/ point to: 1075812784
Hi,
This is not a bug in the compiler.
For fundamental types, a direct-new-expression of the form 'new T'
does -not- do default initialization. If you hve to say
new T()
to get default initialization. Please note the parens.
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/3827: new int problem.
@ 2001-07-30 17:06 Franck Branjonneau
0 siblings, 0 replies; 3+ messages in thread
From: Franck Branjonneau @ 2001-07-30 17:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
The following reply was made to PR c++/3827; it has been noted by GNATS.
From: Franck Branjonneau <franck@tchume.net>
To: Gabriel Dos Reis <gdr@codesourcery.com>
Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org
Subject: Re: c++/3827: new int problem.
Date: Tue, 31 Jul 2001 00:28:09 +0200
Bonjour,
Le 26 juillet 2001, Gabriel Dos Reis a écrit :
> This is not a bug in the compiler.
Yes ! I apologize for the inconvenient.
--
Boujou t'chu tè.
Franck Branjonneau <fasbjx@free.fr>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-07-30 17:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-25 17:36 c++/3827: new int problem fasbjx, Branjonneau
2001-07-26 0:26 Gabriel Dos Reis
2001-07-30 17:06 Franck Branjonneau
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).