[llvm-bugs] [Bug 47734] New: std::numeric_limits doesn't fail when used with non-arithmetic data types

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 5 12:54:49 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47734

            Bug ID: 47734
           Summary: std::numeric_limits doesn't fail when used with
                    non-arithmetic data types
           Product: libc++
           Version: 11.0
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yuri at tsoft.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 24022
  --> https://bugs.llvm.org/attachment.cgi?id=24022&action=edit
testcase-numeric_limits-doesnt-fail-on-non-arithmetic-types.cpp

The attached testcase uses std::numeric_limits on a regular class (a
non-arithmetic type) and compilation doesn't fail.

https://en.cppreference.com/w/cpp/types/numeric_limits says that
> numeric_limits class template provides a standardized way to query various properties of arithmetic types"

This implies that it isn't applicable to non-arithmetic types. Therefore,
std::numeric_limits should be left undefined for all non-arithmetic types so
that the errors with its use can be caught by the compiler.

Specifically, I got std::numeric_limits<Z>::min_exponent10 evaluated to zero
for a regular class type, which caused a division by zero error that had to be
caught by the compiler.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201005/d17e7f06/attachment.html>


More information about the llvm-bugs mailing list