public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55885] New: Modulo operator crashes for int and long variables if they have minimal value
@ 2013-01-06 10:50 klaus.wieder at endolandia dot de
  2013-01-06 11:01 ` [Bug c++/55885] " schwab@linux-m68k.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: klaus.wieder at endolandia dot de @ 2013-01-06 10:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55885

             Bug #: 55885
           Summary: Modulo operator crashes for int and long variables if
                    they have minimal value
    Classification: Unclassified
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: klaus.wieder@endolandia.de


Error description in source file
-------------------------------------

Compiled with
-------------------------------------
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658)
(LLVM build 2336.11.00) on MAC OS X Version 10.7.5 (Lion)
-------------------------------------

Result of gcc -v:
-------------------------------------
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure
--disable-checking --enable-werror
--prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2
--mandir=/share/man --enable-languages=c,objc,c++,obj-c++
--program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
--with-slibdir=/usr/lib --build=i686-apple-darwin11
--enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local
--program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11
--target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
-------------------------------------

Compiler and linker output
-------------------------------------
make all 
Building file: ../src/iotest.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -MMD -MP -MF"src/iotest.d"
-MT"src/iotest.d" -o "src/iotest.o" "../src/iotest.cpp"
Finished building: ../src/iotest.cpp

Building target: iotest
Invoking: MacOS X C++ Linker
g++  -o "iotest"  ./src/iotest.o   
Finished building target: iotest
-------------------------------------

Compiling with options -fno-strict-aliasing -fwrapv does not make a difference
-------------------------------------

file: iotest.cpp
-------------------------------------
#include <iostream>
#include <limits>

// Assumption: If a is a signed variable, then a % -1 should always be 0
//
// ok    if myType is of type char or short
// fails if myType is of type int  or long

int main() {

    typedef int myType;

    myType c;

    myType a = std::numeric_limits<myType>::min();
    int    b = -1;

        // always ok
    c = a % -1;
    std::cout << a << ", " << b << ", " << c << std::endl;

        // signals EXC ARITHMETIC:Arithmetic exception 
        // if myType is int or is long 
    c = a % b;
        std:: cout << a << ", " << b << ", " << c << std::endl;

    return 0;
}


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

end of thread, other threads:[~2021-08-22 21:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-06 10:50 [Bug c++/55885] New: Modulo operator crashes for int and long variables if they have minimal value klaus.wieder at endolandia dot de
2013-01-06 11:01 ` [Bug c++/55885] " schwab@linux-m68k.org
2013-01-06 12:14 ` kwieder at polytechnic dot edu.na
2013-01-06 12:26 ` redi at gcc dot gnu.org
2013-01-06 12:45 ` kwieder at polytechnic dot edu.na
2013-01-07 15:34 ` joseph at codesourcery dot com
2021-08-22 21:52 ` pinskia at gcc dot gnu.org
2021-08-22 21:53 ` pinskia at gcc dot gnu.org
2021-08-22 21:56 ` pinskia at gcc dot gnu.org

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