Your message dated Sun, 28 Mar 2004 14:44:14 +0200 with message-id <[EMAIL PROTECTED]> and subject line Bug#240070: g++ generates wrong code has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what I am talking about this indicates a serious mail system misconfiguration somewhere. Please contact me immediately.) Debian bug tracking system administrator (administrator, Debian Bugs database) -------------------------------------- Received: (at submit) by bugs.debian.org; 25 Mar 2004 17:39:46 +0000 >From [EMAIL PROTECTED] Thu Mar 25 09:39:46 2004 Return-path: <[EMAIL PROTECTED]> Received: from moutng.kundenserver.de [212.227.126.186] by spohr.debian.org with esmtp (Exim 3.35 1 (Debian)) id 1B6YpW-00051m-00; Thu, 25 Mar 2004 09:39:46 -0800 Received: from [212.227.126.155] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1B6YpV-0007eu-00; Thu, 25 Mar 2004 18:39:45 +0100 Received: from [212.9.166.27] (helo=grobi.hamsternet) by mrelayng.kundenserver.de with asmtp (TLSv1:EDH-RSA-DES-CBC3-SHA:168) (Exim 3.35 #1) id 1B6YpU-0003tP-00; Thu, 25 Mar 2004 18:39:45 +0100 Received: from mah by grobi.hamsternet with local (Exim 3.35 #1 (Debian)) id 1B6Yn2-0006gP-00; Thu, 25 Mar 2004 18:37:12 +0100 Date: Thu, 25 Mar 2004 18:37:12 +0100 From: Martin Haller <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: g++ generates wrong code Message-ID: <[EMAIL PROTECTED]> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline User-Agent: Mutt/1.3.28i Sender: Martin Haller <[EMAIL PROTECTED]> X-Provags-ID: kundenserver.de [EMAIL PROTECTED] auth:f7ae1794aa6626a14ec6e854745623ce Delivered-To: [EMAIL PROTECTED] X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 (1.212-2003-09-23-exp) on spohr.debian.org X-Spam-Status: No, hits=-7.0 required=4.0 tests=BAYES_00,HAS_PACKAGE autolearn=no version=2.60-bugs.debian.org_2004_03_25 X-Spam-Level: --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Package: g++-2.95 Version: 2.95.4-11woody1 Package: g++-3.0 Version: 3.0.4-7 Hi, the bug wich I describe below seems to be in both packages - this is the reason why I write one report with two packages - sorry. Problem: -------- Compiling my test code with and without -O2 compiler option generates different behaviors. The test code is attached (it is a TCP Server wich select()s on the different connections - it's really ugly and unstructured - please tell me if you don't come along with it!). Reproduction: ------------- - compile the attached server.cc mit the contributed Makefile; one time with and one time without -O2 Option - start the "server" binaries and connect to port 2000 with telnet: $ telnet localhost 2000 - One time the connection will be established, the other time, accept() will fail with error: invalid argument I have reproduced this behavior on different Debian-3.0 boxes. To be sure I tested it on FreeBSD and (old) Redhat as well: They don't have this effect. I have another test code example, wich one time segfaults and the other time works. Please tell me if you are interested in more code. Overview: --------- System: Compiler: with -O2 without -O2 --------------------------------------------------------------------- Debian-3.0 g++-2.954-11woody1 works fails! Debian-3.0 g++-3.0.4-7 fails! works FreeBSD-4.9 g++-2.95.4 works works Redhat-7.0 g++-2.96 20000731 works works -- Martin --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Makefile CC=g++-3.0 all: $(CC) -c server.cc -g -O2 # $(CC) -c server.cc -g $(CC) -o server server.o -lstdc++ clean: rm -f *.o server --dDRMvlgZJXvWKvBx Content-Type: text/x-c++src; charset=us-ascii Content-Disposition: attachment; filename="server.cc" #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/time.h> #include <sys/poll.h> #include <list.h> typedef list<int> intlist; void initFDSet(int *maxfds, fd_set *set, int serverSocket, intlist *clients) { /* Initialize the file descriptor set. */ FD_ZERO (set); FD_SET (serverSocket, set); *maxfds = serverSocket; for (list<int>::iterator i = clients->begin(); i != clients->end(); i++) { FD_SET(*i,set); if (*i > *maxfds) *maxfds = *i; } } int main() { struct sockaddr_in sin; struct sockaddr_in pin; socklen_t addrlen; int i; struct timeval timeout; int maxfds; int _serverSocket; int client; list<int> clients; fd_set set; if ((_serverSocket = socket(PF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } i = 1; setsockopt(_serverSocket,SOL_SOCKET,SO_REUSEADDR, &i, sizeof(i)); /* complete the socket structure */ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(2000); /* bind the socket to the port number */ if (bind(_serverSocket, (struct sockaddr *) &sin, sizeof(sin)) == -1) { perror("bind"); exit(1); } /* show that we are willing to listen */ if (listen(_serverSocket, 128) == -1) { perror("listen"); exit(1); } /* Initialize the timeout data structure. */ timeout.tv_sec = 5; timeout.tv_usec = 0; initFDSet(&maxfds,&set,_serverSocket,&clients); while (1) { select (maxfds + 1, &set, NULL, NULL, &timeout); if (FD_ISSET(_serverSocket,&set)) { // new connection printf("new connection\n"); if ((client = accept(_serverSocket, (struct sockaddr *) &pin, &addrlen)) == -1) { perror("accept"); exit(1); } clients.push_back(client); } for (list<int>::iterator i = clients.begin(); i != clients.end(); i++) { client = *i; if (FD_ISSET(client,&set)) { char buf[512]; int size = recv(client,buf,sizeof(buf),0); if (! size) { clients.remove(client); close(client); printf("%X client closed connection\n",client); break; } else { buf[size] = 0; printf("%X recv: %d - %s\n",client,size,buf); } } } initFDSet(&maxfds,&set,_serverSocket,&clients); } } --dDRMvlgZJXvWKvBx-- --------------------------------------- Received: (at 240070-done) by bugs.debian.org; 28 Mar 2004 12:49:02 +0000 >From [EMAIL PROTECTED] Sun Mar 28 04:49:02 2004 Return-path: <[EMAIL PROTECTED]> Received: from mail.cs.tu-berlin.de [130.149.17.13] (root) by spohr.debian.org with esmtp (Exim 3.35 1 (Debian)) id 1B7Zio-0001Ol-00; Sun, 28 Mar 2004 04:49:02 -0800 Received: from bolero.cs.tu-berlin.de ([EMAIL PROTECTED] [130.149.19.1]) by mail.cs.tu-berlin.de (8.9.3p2/8.9.3) with ESMTP id OAA10754; Sun, 28 Mar 2004 14:44:15 +0200 (MET DST) Received: (from [EMAIL PROTECTED]) by bolero.cs.tu-berlin.de (8.12.10+Sun/8.12.8/Submit) id i2SCiFuw023824; Sun, 28 Mar 2004 14:44:15 +0200 (MEST) From: Matthias Klose <[EMAIL PROTECTED]> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <[EMAIL PROTECTED]> Date: Sun, 28 Mar 2004 14:44:14 +0200 To: Martin Haller <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Subject: Re: Bug#240070: g++ generates wrong code In-Reply-To: <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid Delivered-To: [EMAIL PROTECTED] X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 (1.212-2003-09-23-exp) on spohr.debian.org X-Spam-Status: No, hits=-5.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER autolearn=no version=2.60-bugs.debian.org_2004_03_25 X-Spam-Level: Fixed in the default version of the current testing/unstable distributen (gcc-3.3.3). Martin Haller writes: > Package: g++-2.95 > Version: 2.95.4-11woody1 > > Package: g++-3.0 > Version: 3.0.4-7 > > > Hi, > > the bug wich I describe below seems to be in both packages - this is > the reason why I write one report with two packages - sorry. > > Problem: > -------- > > Compiling my test code with and without -O2 compiler option generates > different behaviors. The test code is attached (it is a TCP Server > wich select()s on the different connections - it's really ugly and > unstructured - please tell me if you don't come along with it!). > > Reproduction: > ------------- > > - compile the attached server.cc mit the contributed Makefile; one > time with and one time without -O2 Option > - start the "server" binaries and connect to port 2000 with telnet: > $ telnet localhost 2000 > - One time the connection will be established, the other time, > accept() will fail with error: invalid argument > > I have reproduced this behavior on different Debian-3.0 boxes. To be > sure I tested it on FreeBSD and (old) Redhat as well: They don't have > this effect. > > I have another test code example, wich one time segfaults and the > other time works. Please tell me if you are interested in more code. > > > Overview: > --------- > > System: Compiler: with -O2 without -O2 > --------------------------------------------------------------------- > Debian-3.0 g++-2.954-11woody1 works fails! > Debian-3.0 g++-3.0.4-7 fails! works > FreeBSD-4.9 g++-2.95.4 works works > Redhat-7.0 g++-2.96 20000731 works works