Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-65

std::numeric_limits<int>::traps = false when integer arithmetic traps

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.1.3
    • Component/s: 18. Language Support
    • Labels:
      None
    • Environment:

      all

      Description

      The program below aborts. See also the related LWG issue 497:
      http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#497

      $ cat t.cpp && nice make t -r CPPOPTS=-DSIGTRAP=5 && ./t
      #include <cassert>
      #include <csetjmp>
      #include <csignal>
      #include <limits>

      std::jmp_buf env;

      extern "C" void handle_trap (int)
      {
      std::longjmp (env, 1);
      }

      volatile int zero;

      int main ()
      {
      const bool traps = std::numeric_limits<int>::traps;

      bool trapped = false;

      std::signal (SIGFPE, handle_trap);
      std::signal (SIGTRAP, handle_trap);
      if (0 == setjmp (env))

      { zero = 2 / zero; }

      else

      { trapped = true; }

      assert (traps && trapped || !traps && !trapped);
      }
      eccp -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/build/sebor/eccp-3.6-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -DSIGTRAP=5 -A -x --template_directory=/build/sebor/eccp-3.6-11s/lib -g --display_error_number --remarks --diag_suppress 193,236,340,401,261,479,487,678,679,815 t.cpp
      eccp t.o -o t -L/build/sebor/eccp-3.6-11s/rwtest -lrwtest11s --template_directory=/build/sebor/eccp-3.6-11s/lib -L/build/sebor/eccp-3.6-11s/lib -lstd11s -lm
      t.cpp:30: Assertion 'traps && trapped || !traps && !trapped' failed.
      /build/sebor/eccp-3.6-11s/tests/t:_rw_assert_fail4_rwFPCcT1iT1+0x84
      /build/sebor/eccp-3.6-11s/tests/t:main+0xcc
      /build/sebor/eccp-3.6-11s/tests/t:_start+0x5c
      Abort (core dumped)

        Attachments

          Activity

            People

            • Assignee:
              sebor Martin Sebor
              Reporter:
              sebor Martin Sebor
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: