public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37854] New: No error when creating a variable from itself
@ 2008-10-16 16:03 julien dot sagnard at gmail dot com
2008-10-16 16:18 ` [Bug c++/37854] " paolo dot carlini at oracle dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: julien dot sagnard at gmail dot com @ 2008-10-16 16:03 UTC (permalink / raw)
To: gcc-bugs
If I try to compile this code:
class X {};
int main {
int i = i;
X x = x;
X y(y);
return 0;
}
With:
gcc -Wall main.cpp
There is no error and no warning.
INFOS:
OS:
Ubuntu Hardy
gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
uname -a
Linux VmWare-Ubuntu 2.6.24-19-generic #1 SMP Fri Jul 11 23:41:49 UTC 2008 i686
GNU/Linux
--
Summary: No error when creating a variable from itself
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: julien dot sagnard at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/37854] No error when creating a variable from itself
2008-10-16 16:03 [Bug c++/37854] New: No error when creating a variable from itself julien dot sagnard at gmail dot com
@ 2008-10-16 16:18 ` paolo dot carlini at oracle dot com
2008-10-16 16:20 ` paolo dot carlini at oracle dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-16 16:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from paolo dot carlini at oracle dot com 2008-10-16 16:16 -------
*** This bug has been marked as a duplicate of 34772 ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/37854] No error when creating a variable from itself
2008-10-16 16:03 [Bug c++/37854] New: No error when creating a variable from itself julien dot sagnard at gmail dot com
2008-10-16 16:18 ` [Bug c++/37854] " paolo dot carlini at oracle dot com
@ 2008-10-16 16:20 ` paolo dot carlini at oracle dot com
2008-10-16 16:23 ` paolo dot carlini at oracle dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-16 16:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from paolo dot carlini at oracle dot com 2008-10-16 16:18 -------
Oops, sorry.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|DUPLICATE |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/37854] No error when creating a variable from itself
2008-10-16 16:03 [Bug c++/37854] New: No error when creating a variable from itself julien dot sagnard at gmail dot com
2008-10-16 16:18 ` [Bug c++/37854] " paolo dot carlini at oracle dot com
2008-10-16 16:20 ` paolo dot carlini at oracle dot com
@ 2008-10-16 16:23 ` paolo dot carlini at oracle dot com
2008-10-16 19:09 ` pinskia at gcc dot gnu dot org
2008-10-21 20:59 ` manu at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-16 16:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from paolo dot carlini at oracle dot com 2008-10-16 16:22 -------
In mainline (would be 4.4.0), with -Winit-self a warning is emitted for line 4
only. EDG-based compilers apparently do the same...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/37854] No error when creating a variable from itself
2008-10-16 16:03 [Bug c++/37854] New: No error when creating a variable from itself julien dot sagnard at gmail dot com
` (2 preceding siblings ...)
2008-10-16 16:23 ` paolo dot carlini at oracle dot com
@ 2008-10-16 19:09 ` pinskia at gcc dot gnu dot org
2008-10-21 20:59 ` manu at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-10-16 19:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2008-10-16 19:08 -------
In this case since x and y are empty structs there are no real uses of them.
If I change the code to:
struct X {int i;};
int main()
{
int i = i;
X x = x;
X y(y);
return i+x.i+y.i;
}
--- CUT ---
And turn on optimization, I get the following warnings:
t.c: In function 'int main()':
t.c:5: warning: 'i' is used uninitialized in this function
t.c:8: warning: 'x.X::i' is used uninitialized in this function
t.c:8: warning: 'y.X::i' is used uninitialized in this function
Note all of the above warnings should only happen with -Winit-self (which works
correctly with the C front-end and is PR 34772 ).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/37854] No error when creating a variable from itself
2008-10-16 16:03 [Bug c++/37854] New: No error when creating a variable from itself julien dot sagnard at gmail dot com
` (3 preceding siblings ...)
2008-10-16 19:09 ` pinskia at gcc dot gnu dot org
@ 2008-10-21 20:59 ` manu at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-10-21 20:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from manu at gcc dot gnu dot org 2008-10-21 20:58 -------
Given Andrew's comments, this is not a bug. Thanks for the report nonetheless.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-21 20:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-16 16:03 [Bug c++/37854] New: No error when creating a variable from itself julien dot sagnard at gmail dot com
2008-10-16 16:18 ` [Bug c++/37854] " paolo dot carlini at oracle dot com
2008-10-16 16:20 ` paolo dot carlini at oracle dot com
2008-10-16 16:23 ` paolo dot carlini at oracle dot com
2008-10-16 19:09 ` pinskia at gcc dot gnu dot org
2008-10-21 20:59 ` manu 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).