[ 
https://issues.apache.org/jira/browse/STDCXX-624?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Sebor updated STDCXX-624:
--------------------------------

    Description: 
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|http://svn.apache.org/repos/asf/stdcxx/trunk/examples/manual/limits.cpp]
 produces a {{DIFF}} result in some builds).

{code}
$ 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
{code}


  was:
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


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

> [gcc/Linux] std::numeric_limits<int>::traps = false when integer arithmetic 
> traps
> ---------------------------------------------------------------------------------
>
>                 Key: STDCXX-624
>                 URL: https://issues.apache.org/jira/browse/STDCXX-624
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 18. Language Support
>    Affects Versions: 4.2.0
>         Environment: gcc 4.1.0 on SUSE Linux Enterprise Server 10 (x86_64)
>            Reporter: Martin Sebor
>            Assignee: Martin Sebor
>            Priority: Trivial
>             Fix For: 4.2.1
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> 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|http://svn.apache.org/repos/asf/stdcxx/trunk/examples/manual/limits.cpp]
>  produces a {{DIFF}} result in some builds).
> {code}
> $ 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
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to