Bug 9088 - c code aborts with -ftrapv
Summary: c code aborts with -ftrapv
Status: RESOLVED DUPLICATE of bug 1823
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-28 16:26 UTC by wefing
Modified: 2003-07-06 17:30 UTC (History)
2 users (show)

See Also:
Host: i486-suse-linux-gnu
Target: i486-suse-linux-gnu
Build: i486-suse-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wefing 2002-12-28 16:26:00 UTC
simple c code using pointer arithmetics aborts if compiled with -ftrapv.
may be related to PR 9097.

Release:
3.2

Environment:
System: Linux kato 2.4.19-64GB-SMP #1 SMP Fri Sep 13 13:15:53 UTC 2002 i686 unknown
Architecture: i686
Linux-Distribution: SuSE Professional 8.1

host: i486-suse-linux-gnu
build: i486-suse-linux-gnu
target: i486-suse-linux-gnu
configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i486-suse-linux

How-To-Repeat:
kato wefing/tmp> cat prog.c

int main(void)
{
   struct s
   {
      int i;
      double x;
   };
   
   struct s a[2];
   struct s *p=a+1;
   int i=p-a;

   return 0;
}

kato wefing/tmp> gcc -o prog prog.c
kato wefing/tmp> ./prog
kato wefing/tmp> gcc -ftrapv -o prog prog.c
kato wefing/tmp> ./prog
Abort (core dumped)
Exit 134
kato wefing/tmp> gcc -g -ftrapv -o prog prog.c
kato wefing/tmp> ./prog
Abort (core dumped)
Exit 134
kato wefing/tmp> gdb ./prog core
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...
Core was generated by `./prog'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x4004edf1 in kill () from /lib/libc.so.6
(gdb) w
#0  0x4004edf1 in kill () from /lib/libc.so.6
#1  0x4004ebd8 in raise () from /lib/libc.so.6
#2  0x400504d9 in abort () from /lib/libc.so.6
#3  0x08048452 in __mulvsi3 () at ../../gcc/libgcc2.c:144
#4  0x08048378 in main () at prog.c:11
#5  0x4003d4a2 in __libc_start_main () from /lib/libc.so.6
(gdb) f 4
#4  0x08048378 in main () at prog.c:11
11         int i=p-a;
Comment 1 Wolfgang Bangerth 2003-01-07 18:53:45 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 2 Volker Reichelt 2003-01-08 12:14:55 UTC
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, wefing@gmx.de, gcc-bugs@gcc.gnu.org
Cc:  
Subject: Re: c/9088: c code aborts with -ftrapv
Date: Wed, 8 Jan 2003 12:14:55 +0100

 The bug seems to affect all versions since gcc 3.0 when the option was
 introduced (including 3.2-branch, 3.3-branch and mainline).
 
 The bug seems to be target-dependant, since I cannot reproduce it on
 mips-sgi-irix6.5.
 
 Regards,
 Volker
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9088
Comment 3 Falk Hueffner 2003-07-06 17:30:51 UTC

*** This bug has been marked as a duplicate of 1823 ***