[llvm-bugs] [Bug 51582] New: /permissive- and Implicit conversion of integral constant expressions to null pointer.
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 23 03:25:28 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51582
Bug ID: 51582
Summary: /permissive- and Implicit conversion of integral
constant expressions to null pointer.
Product: clang
Version: 12.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: tormardi at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Created attachment 25182
--> https://bugs.llvm.org/attachment.cgi?id=25182&action=edit
Bad overload chosen, -Wnon-literal-null-conversion
From
https://docs.microsoft.com/en-us/cpp/overview/cpp-conformance-improvements?view=msvc-160&viewFallbackFrom=vs-2019#implicit\
\-conversion-of-integral-constant-expressions-to-null-pointer
"The MSVC compiler now implements CWG Issue 903 in conformance mode
(/permissive-). This rule disallows implicit conversion of integral
constant expressions (except for the integer literal '0') to null
pointer constants."
The attached snippet, built with clang 12.0.1 for windows outputs
CTOR two
CTOR three
And so does Visual Studio with "/permissive"
With "/permissive-" Visual Studio gets it right.
clang says:
warning: expression which evaluates to zero treated as a null pointer
constant of type 'int *const'
[-Wnon-literal-null-conversion]
If I remove 'constexpr' the warning goes away, and we get correct behaviour.
--
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/20210823/43f9043d/attachment.html>
More information about the llvm-bugs
mailing list