NetBSD Problem Report #46033
From martin@duskware.de Thu Feb 16 21:46:24 2012
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id C7B2563D712
for <gnats-bugs@gnats.NetBSD.org>; Thu, 16 Feb 2012 21:46:23 +0000 (UTC)
Message-Id: <20120216214623.C7B2563D712@www.NetBSD.org>
Date: Thu, 16 Feb 2012 21:46:23 +0000 (UTC)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: gcc miscompiles tcl config test
X-Send-Pr-Version: 3.95
>Number: 46033
>Category: toolchain
>Synopsis: gcc miscompiles tcl config test
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 16 21:50:00 +0000 2012
>Last-Modified: Tue May 01 11:30:18 +0000 2012
>Originator: Martin Husemann
>Release: NetBSD 5.99.65
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD dead-to-the-world.duskware.de 5.99.65 NetBSD 5.99.65 (DEAD) #51: Tue Feb 14 22:38:47 CET 2012 martin@night-porter.duskware.de:/usr/src/sys/arch/vax/compile/DEAD vax
Architecture: vax
Machine: vax
>Description:
With gcc 4.5.3 the following (closely based on a config test from pkgsrc/lang/tcl)
fails to complete:
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int main ()
{
int i;
for (i = 0; i < 256; i++) {
printf("testing with i = %d\n", i);
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
exit(2);
}
printf("done\n");
return 0;
}
Compiling this causes strange warnings
conftest.c:16:7: warning: 'iftmp.4' may be used uninitialized in this function
and the value of i is always 0.
>How-To-Repeat:
s/a
>Fix:
n/a
>Audit-Trail:
From: David Brownlee <abs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: port-vax@netbsd.org
Subject: Re: toolchain/46033: gcc miscompiles tcl config test
Date: Tue, 1 May 2012 12:30:14 +0100
Had a quick play and found something interesting - this only shows up
under the native compiler, not a cross compiler
./build.sh -m vax ... tools
.../vax--netbsdelf-gcc -O2 -c conftest.c ; scp conftest.o root@vax
vax# cc -o a.out conftest.o ; ./a.out
[... valid output ...]
Not that this particularly helps, just to show that the test shows up
an issue in the compiler compiling gcc source, rather than itself :)
(Tested with -O2, -O and no -O)
[original source below]
> With gcc 4.5.3 the following (closely based on a config test from pkgsrc/=
lang/tcl)
> fails to complete:
>
> #include <ctype.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> #define ISLOWER(c) ('a' <=3D (c) && (c) <=3D 'z')
> #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
> #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
>
> int main ()
> {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0int i;
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < 256; i++) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("testing wi=
th i =3D %d\n", i);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (XOR (islower (=
i), ISLOWER (i))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|| t=
oupper (i) !=3D TOUPPER (i))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0exit(2);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("done\n");
> =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
> }
>
> Compiling this causes strange warnings
>
> conftest.c:16:7: warning: 'iftmp.4' may be used uninitialized in this fun=
ction
>
> and the value of i is always 0.
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.