public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8371: Self initialization
@ 2002-10-27 15:06 jorgen
  0 siblings, 0 replies; 2+ messages in thread
From: jorgen @ 2002-10-27 15:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8371
>Category:       c++
>Synopsis:       Self initialization
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 27 15:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     jorgen@profitab.com
>Release:        gcc version 3.2.1 20021020 (Debian prerelease)
>Organization:
>Environment:
Linux Debian GNU/Linux sid/unstable
>Description:
I've found a possible illegal statement in the C++ compiler as well as the C compiler. I detected the problem first using g++ (C++), but discovered that the same behaviour can be seen using gcc (C). 

Self initialization is legal according to the compilers. As I don't have the language reference manual, nor did I find anything on the net, I'm inclined to believe this is a bug. It does not make sense to allow self initialization. At the very least, the compiler should issue a warning. No such warning is issued with -Wall.

Not only did I find this in the Debian gcc 3.2.1 compiler, I also found it in the Debian 2.95.4 20011002 (prerelease) compiler as well as in the OpenBSD 2.95.3 20010125 (prerelease) compiler.

Attached is a single file containing the C++ source for reproducing the error as well as the output from the command "g++-3.2 -Wall -v -save-temps tst.cpp". No preprocessed files are attached as I'm not including any header files. 
>How-To-Repeat:
Extract the C++ code from the attached file and compile it using -Wall. No warnings - no errors.

Of course, the variable x contains garbage - verify with std::cout.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bugreport.txt"
Content-Disposition: inline; filename="bugreport.txt"

C++ Source begins here: 

int main(void) {
	int x = x;
	return 0;
}



Output from g++ -Wall -v -save-temps tst.cpp here: 

Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.1/specs
Configured with: /mnt/data/gcc-3.1/gcc-3.2-3.2.1ds3/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.1 20021020 (Debian prerelease)
 /usr/lib/gcc-lib/i386-linux/3.2.1/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ tst.cpp -Wall tst.ii
GNU CPP version 3.2.1 20021020 (Debian prerelease) (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/i386-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2
 /usr/include/c++/3.2/i386-linux
 /usr/include/c++/3.2/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-linux/3.2.1/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-linux/3.2.1/cc1plus -fpreprocessed tst.ii -quiet -dumpbase tst.cpp -Wall -version -o tst.s
GNU CPP version 3.2.1 20021020 (Debian prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.1 20021020 (Debian prerelease) (i386-linux)
	compiled by GNU C version 3.2.1 20021020 (Debian prerelease).
 as -V -Qy -o tst.o tst.s
GNU assembler version 2.13.90.0.10 (i386-linux) using BFD version 2.13.90.0.10 20021010 Debian GNU/Linux
 /usr/lib/gcc-lib/i386-linux/3.2.1/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i386-linux/3.2.1/../../../crt1.o /usr/lib/gcc-lib/i386-linux/3.2.1/../../../crti.o /usr/lib/gcc-lib/i386-linux/3.2.1/crtbegin.o -L/usr/lib/gcc-lib/i386-linux/3.2.1 -L/usr/lib/gcc-lib/i386-linux/3.2.1/../../.. tst.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/i386-linux/3.2.1/crtend.o /usr/lib/gcc-lib/i386-linux/3.2.1/../../../crtn.o


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

* Re: c++/8371: Self initialization
@ 2002-10-27 16:02 paolo
  0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2002-10-27 16:02 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jorgen, nobody

Synopsis: Self initialization

State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Sun Oct 27 16:02:55 2002
State-Changed-Why:
    Duplicate of c/5582. See also the discussion thread starting
    here: http://gcc.gnu.org/ml/gcc/2002-02/msg00045.html.
    Thanks for your report, Paolo.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8371


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

end of thread, other threads:[~2002-10-28  0:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-27 15:06 c++/8371: Self initialization jorgen
2002-10-27 16:02 paolo

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).