MSVC turns on /Zc:alignedNew for C++17 by default and /Zc:sizedDealloc by default
https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170
 Differential  D127641  
[clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default Authored by steplong on Jun 13 2022, 7:45 AM. 
Details MSVC turns on /Zc:alignedNew for C++17 by default and /Zc:sizedDealloc by default https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170 
Diff Detail 
 Event TimelineComment Actions I'm not sure how to check for /std: at this stage to turn on arguments like /Zc:alignedNew 
 
 
 Comment Actions Comment Actions 
 
 Comment Actions https://docs.microsoft.com/en-us/cpp/build/reference/zc-sizeddealloc-enable-global-sized-dealloc-functions?view=msvc-170 says it implements this by default starting on MSVC 2015. I don't have an older version of MSVC, so maybe someone can confirm for me Comment Actions lgtm (If you like, consider dropping the "-DEFAULT" part from the new filecheck prefixes. I don't think they really add much value.) Comment Actions It looks like misc-new-delete-overloads.cpp is failing on line 20:  1 // RUN: %check_clang_tidy %s misc-new-delete-overloads %t
 2
 3 typedef decltype(sizeof(int)) size_t;
 4
 5 struct S {
 6   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope [misc-new-delete-overloads]
 7   void *operator new(size_t size) noexcept;
 8   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new[]' has no matching declaration of 'operator delete[]' at the same scope
 9   void *operator new[](size_t size) noexcept;
10 };
11
12 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope
13 void *operator new(size_t size) noexcept(false);
14
15 struct T {
16   // Sized deallocations are not enabled by default, and so this new/delete pair
17   // does not match. However, we expect only one warning, for the new, because
18   // the operator delete is a placement delete and we do not warn on mismatching
19   // placement operations.
20   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope
21   void *operator new(size_t size) noexcept;
22   void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled
23 };On Line 16, it says sized deallocations are not enabled by default, but this patch turns it on by default for MSVC. Should I unsupport this test for windows or is there a way to pass /Zc:sizedDealloc- only for windows? Comment Actions You could add a target to the test so that it doesn't target windows-msvc, e.g. -target x86_64-unknown-linux. Comment Actions Hmm, a StaticAnalyzer unit test is failing. It looks it is expecting "test.CXXDeallocator: NumArgs: 1\n", but getting `"test.CXXDeallocator: NumArgs: 2\n". I'm assuming it is because sized deallocation is enabled on default for MSVC now Comment Actions 
 I won't merge this. Just want to see if this passes the unittest 
 
 Comment Actions 
 The regex isn't optimal since it will still accept strings that aren't "Num Args: 1\n" or "Num Args: 2\n" such as "Num Args: \n2\n"  | ||||||||||||||||||||||||||||||||||||||||||
Only for C++17, and not C++17 and above?