This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Reference declaration with self-assignment. Is it legal? G++ says it is!
- From: Carlos Ferreira <carlosmf dot pt at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 15 May 2015 11:51:11 +0100
- Subject: Reference declaration with self-assignment. Is it legal? G++ says it is!
- Authentication-results: sourceware.org; auth=none
Hello to all!
I would like to make a quick question.
G++ seems to allow this:
int& x = x;
which creates a null int reference. Why does G++ allows this? Is it a
standard thing? This doesn't even generates a warning, and such code can
easily cause a segfault.
Thanks for the info
Carlos Miguel Ferreira