Issue Details (XML | Word | Printable)

Key: STDCXX-624
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Martin Sebor
Reporter: Martin Sebor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

[gcc/Linux] std::numeric_limits<int>::traps = false when integer arithmetic traps

Created: 29/Oct/07 11:35 PM   Updated: 30/Mar/08 11:52 PM
Return to search
Component/s: 18. Language Support
Affects Version/s: 4.2.0
Fix Version/s: 4.2.1

Time Tracking:
Original Estimate: 4h
Original Estimate - 4h
Remaining Estimate: 2h
Time Spent - 2h Remaining Estimate - 2h
Time Spent: 2h
Time Spent - 2h Remaining Estimate - 2h

Environment: gcc 4.1.0 on SUSE Linux Enterprise Server 10 (x86_64)

Severity: Incorrect Behavior
Resolution Date: 30/Mar/08 11:52 PM


 Description  « Hide
As an extension, stdcxx defines the value of std::numeric_limits<T>::traps for integer T to be true when there exists an arithmetic operation on type T that traps for some value of T. Based on this definition the program below should always run successfully to completion but when compiled with gcc 4.1.0 with optimization enabled on SUSE Linux Enterprise Server 10 (x86_64) it aborts at runtime. (This is also why the example program limits.cpp produces a DIFF result in some builds).
$ cat t.cpp && make t && ./t
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <limits>

char digits[] = " +0.?23456789e+01";

int main ()
{
    digits [4] = '0';
    const int zero = (int)std::strtod (digits, 0);

    digits [4] = '1';
    const int x = (int)std::strtod (digits, 0);

    if (!std::numeric_limits<int>::traps) {
        const int div = x / zero;
        const int mod = x % zero;

        std::printf ("%d, %d\n", div, mod);
    }
}
gcc -c -I/amd/devco/sebor/stdcxx-4.2.x/include/ansi   -pthread -I/amd/devco/sebor/stdcxx-4.2.x/include -I/build/sebor/stdcxx-4.2.x-gcc-4.1.0-12D/include -I/amd/devco/sebor/stdcxx-4.2.x/examples/include  -pedantic -nostdinc++ -O2   -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align   t.cpp
gcc t.o -o t -pthread  -L/build/sebor/stdcxx-4.2.x-gcc-4.1.0-12D/lib  -Wl,-R/build/sebor/stdcxx-4.2.x-gcc-4.1.0-12D/lib -lstd12D -lsupc++ -lm 
Floating point exception


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #589912 Mon Oct 29 23:40:50 UTC 2007 sebor 2007-10-29 Martin Sebor <sebor@roguewave.com>

STDCXX-624
* etc/config/src/NO_INT_TRAPS.cpp (main): Worked even harder to foil
optimizers and trigger a trap (such as SIGFPE) for integer arithmetic.
Files Changed
MODIFY /incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp

Repository Revision Date User Message
ASF #589913 Mon Oct 29 23:41:53 UTC 2007 sebor 2007-10-29 Martin Sebor <sebor@roguewave.com>

Merged rev 589912 (fix for STDCXX-624) from branches/4.2.x.
* NO_INT_TRAPS.cpp (main): Worked even harder to foil optimizers
and trigger a trap (such as SIGFPE) for integer arithmetic.
Files Changed
MODIFY /incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp

Repository Revision Date User Message
ASF #641091 Wed Mar 26 00:12:57 UTC 2008 sebor 2008-03-25 Martin Sebor <sebor@roguewave.com>

* tests/regress/18.limits.traps.STDCXX-624.cpp: Added a regression
test for STDCXX-624.
Files Changed
ADD /stdcxx/trunk/tests/regress/18.limits.traps.stdcxx-624.cpp

Repository Revision Date User Message
ASF #642845 Sun Mar 30 23:53:44 UTC 2008 sebor 2008-03-30 Martin Sebor <sebor@roguewave.com>

Merged rev 641091 from trunk.
* tests/regress/18.limits.traps.STDCXX-624.cpp: Added a regression
test for STDCXX-624.
Files Changed
ADD /stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp (from /stdcxx/trunk/tests/regress/18.limits.traps.stdcxx-624.cpp)