Monday, April 13, 2020

Digest for comp.lang.c++@googlegroups.com - 12 updates in 5 topics

Bob Langelaan <bobl0456@gmail.com>: Apr 13 09:13AM -0700

This code used to work in earlier version of MS VS 2019:
 
vector<size_t> v1(two_hundred_million);
 
for (int i = 0; i < two_hundred_million; ++i) {
v1[i] = randomInt(engine);// random number 1 to 4 billion
}
 
sort(execution::par, v1.begin(), v1.end());
 
Now exits with following message:
 
C:\Users\bobl0\Documents\Visual Studio 2019\Projects\BobDebug4\Release\BobDebug4.exe (process 22908) exited with code -1073740791.
Press any key to close this window . . .
 
Code executed in Release mode, not Debug mode.
NOTE: When executed in Debug mode, it completes successfully, though it takes 133 seconds to complete where it took 4 seconds in Release mode when that mode still worked.
 
Some additional code defined previous to code shown above:
 
const size_t two_hundred_million = 200000000;
 
default_random_engine engine( static_cast<unsigned int>( time(0) ) );
uniform_int_distribution<size_t> randomInt( 1, four_billion);
 
Default settings in IDE other than I have selected "ISO C++ 17 Standard (for the field "C++ Language Standard"). This is required in order to use this updated version of the sort algorithm.
 
 
 
========================================================================
 
Some additional info pulled from VS IDE:
 
Microsoft Visual Studio Community 2019
Version 16.5.3
VisualStudio.16.Release/16.5.3+30002.166
Microsoft .NET Framework
Version 4.8.03752
 
Installed Version: Community
 
Visual C++ 2019 00435-60000-00000-AA945
Microsoft Visual C++ 2019
 
ASP.NET and Web Tools 2019 16.5.236.49856
ASP.NET and Web Tools 2019
 
Azure App Service Tools v3.0.0 16.5.236.49856
Azure App Service Tools v3.0.0
 
C# Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
 
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
 
Cookiecutter 16.5.20041.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.
 
IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info
 
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30207.1
 
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
 
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
 
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
 
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
 
NuGet Package Manager 5.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
 
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
 
Python 16.5.20041.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.
 
Python - Conda support 16.5.20041.1
Conda support for Python projects.
 
Python - Django support 16.5.20041.1
Provides templates and integration for the Django web framework.
 
Python - IronPython support 16.5.20041.1
Provides templates and integration for IronPython-based projects.
 
Python - Profiling support 16.5.20041.1
Profiling support for Python projects.
 
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
 
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
 
TypeScript Tools 16.0.20225.2001
TypeScript Tools for Microsoft Visual Studio
 
Visual Basic Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
 
Visual F# Tools 10.8.0.0 for F# 4.7 16.5.0-beta.20181.6+85af456066acd4e76d2bc7821b44a325e46f2fca
Microsoft Visual F# Tools 10.8.0.0 for F# 4.7
 
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
 
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
 
Visual Studio Tools for Unity 4.5.1.0
Visual Studio Tools for Unity
 
========================================================================
 
And some more info:
 
OS Name Microsoft Windows 10 Home
Version 10.0.18363 Build 18363
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name DESKTOP-ATH7RCS
System Manufacturer System manufacturer
System Model System Product Name
System Type x64-based PC
System SKU SKU
Processor AMD Ryzen 7 3700X 8-Core Processor, 3593 Mhz, 8 Core(s), 16 Logical Processor(s)
BIOS Version/Date American Megatrends Inc. 0807, 2019-07-08
SMBIOS Version 3.2
Embedded Controller Version 255.255
BIOS Mode UEFI
BaseBoard Manufacturer ASUSTeK COMPUTER INC.
BaseBoard Product TUF GAMING X570-PLUS (WI-FI)
BaseBoard Version Rev X.0x
Platform Role Desktop
Secure Boot State Off
PCR7 Configuration Binding Not Possible
Windows Directory C:\Windows
System Directory C:\Windows\system32
Boot Device \Device\HarddiskVolume2
Locale United States
Hardware Abstraction Layer Version = "10.0.18362.628"
User Name DESKTOP-ATH7RCS\bobl0
Time Zone Pacific Daylight Time
Installed Physical Memory (RAM) 15.9 GB
Total Physical Memory 15.9 GB
Available Physical Memory 4.88 GB
Total Virtual Memory 25.7 GB
Available Virtual Memory 4.35 GB
Page File Space 9.80 GB
Page File C:\pagefile.sys
Kernel DMA Protection Not Available
Virtualization-based security Not enabled
Device Encryption Support Reasons for failed automatic device encryption: TPM is not usable, PCR7 binding is not supported, Hardware Security Test Interface failed and device is not Modern Standby, Un-allowed DMA capable bus/device(s) detected, WinRE is not configured, TPM is not usable
Hyper-V - VM Monitor Mode Extensions Yes
Hyper-V - Second Level Address Translation Extensions Yes
Hyper-V - Virtualization Enabled in Firmware No
Hyper-V - Data Execution Protection Yes
Bonita Montero <Bonita.Montero@gmail.com>: Apr 13 07:58PM +0200

This works:
 
#include <iostream>
#include <random>
#include <limits>
#include <vector>
#include <algorithm>
#include <execution>
 
using namespace std;
 
int main()
{
size_t const COUNT = 200'000'000;
vector<size_t> vec( COUNT );
minstd_rand lce;
uniform_int_distribution<size_t>
uid( 0, numeric_limits<size_t>::max() );
for( size_t &value : vec )
value = uid( lce );
sort( execution::parallel_policy(), vec.begin(), vec.end() );
return EXIT_SUCCESS;
}
Mike Terry <news.dead.person.stones@darjeeling.plus.com>: Apr 13 08:35PM +0100

On 13/04/2020 17:13, Bob Langelaan wrote:
 
> Now exits with following message:
 
> C:\Users\bobl0\Documents\Visual Studio 2019\Projects\BobDebug4\Release\BobDebug4.exe (process 22908) exited with code -1073740791.
> Press any key to close this window . . .
 
-1073740791 is the NTStatus for stack buffer overrun, in case this helps
anyone...
 
Mike.
 
 
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Apr 13 01:23PM -0700


> Now exits with following message:
 
> C:\Users\bobl0\Documents\Visual Studio 2019\Projects\BobDebug4\Release\BobDebug4.exe (process 22908) exited with code -1073740791.
> Press any key to close this window . . .
[153 lines deleted]
 
You provided a lot of information, which I'm sure is helpful.
But the most helpful thing you could provide is a complete
self-contained program that exhibits the problem. If I want to
copy-and-paste your code and try it myself, I have to add enough
declarations to make it compile -- and I can't be certain whether
there are critical differences beween my code and your code.
 
Please show us a complete program, including a fully defined main()
function and all required #include directives.
 
https://stackoverflow.com/help/minimal-reproducible-example
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Bonita Montero <Bonita.Montero@gmail.com>: Apr 13 05:32PM +0200

Why is this allowed ...
union
{
double d = 1.0;
long long ll;
};
... but not this ...
double v = 1.0;
union
{
double d = v;
long long ll;
};
?
Paavo Helde <eesnimi@osa.pri.ee>: Apr 13 09:04AM +0300

12.04.2020 18:30 Alf P. Steinbach kirjutas:
> In passing, why throw a `std::logic_error`? If the logic is astray, then
> best to terminate?
 
This is a more general issue. Most of C++ code resides in various
libraries or may eventually end up in various libraries, and a library
should not decide whether it is appropriate to kill the whole process or
not. This is a task for the main client application.
 
Consider e.g. Python which can be used in interactive regime. You don't
want to kill the whole Python process in some low-level C++
implementation code just because the user mixed up some parameters in
the Python interactive command line.
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 13 01:21AM -0500

Paavo Helde wrote:
> libraries or may eventually end up in various libraries, and a library
> should not decide whether it is appropriate to kill the whole process
> or not. This is a task for the main client application.
 
Well said, that man!
 
The widespread ignorance of that principle is amazing.
 
"Γ–ΓΆ Tiib" <ootiib@hot.ee>: Apr 12 11:47PM -0700

On Monday, 13 April 2020 09:04:18 UTC+3, Paavo Helde wrote:
> want to kill the whole Python process in some low-level C++
> implementation code just because the user mixed up some parameters in
> the Python interactive command line.
 
On current case the else was when std::variant<int64_t, double, std::string>
contained somehow something else but int64_t, double or std::string.
It is not even logic error but case where std::variant somehow managed
to violate its specifications. I would perhaps also abort, that can't
be something that is fixed by catcher.
Manfred <invalid@add.invalid>: Apr 13 01:44AM +0200

On 4/12/20 5:22 PM, Juha Nieminen wrote:
>> OK, I suppose that any destructors for the old element are called of course.
 
> Whatever the assignment operator for the type in question does is done.
> In practice it just works.
 
The requirement is that the assignment operator be correctly defined.
This is obviously true for built-in and std types.
For user defined types the programmer has to take care of it.
James Kuyper <jameskuyper@alumni.caltech.edu>: Apr 12 07:35PM -0700

On Sunday, April 12, 2020 at 5:43:42 AM UTC-4, jacobnavia wrote:
 
> > (Although, admittedly, "position 4" is ambiguous, as it
> > could mean either one.)
 
> OK, I suppose that any destructors for the old element are called of course.
 
Assuming that vec[3] and 4 have the same type (int), then destructors
play no role in the matter, it simply calls the copy assignment
operator. If a class type T were involved, then other possibilities come
up depending upon which operator overloads are, or are not, defined.
Juha Nieminen <nospam@thanks.invalid>: Apr 13 05:57AM


>> myvector.insert(myvector.begin() + 3, 60);
 
> The first line erases the item;  The second line inserts the number 60
> in the 4th place.
 
This is actually an incorrect answer to the question that was
presented.
 
The question asked if the element has to be removed and then the
new one inserted. And the answer is no, that's not needed. You can
simply assign the new value to the element in question.
Juha Nieminen <nospam@thanks.invalid>: Apr 13 05:53AM

> Since it's a reference it won't remove the pointee's `const`.
 
> It does remove the item `const`-ness for an array type, because a const
> raw array of T is a raw array of const T.
 
Everybody's right. I was confused because I didn't really understand
the significance of a string literal parameter being actually of an
array type rather than a pointer type.
 
When given a string literal like "hello", Params_t expands to
char[6] (with its "constness removed"), but the variable itself
will be of a const char[6] type. This can be used in a quite
verbose and roundaway way to get the actual type one wants, like
this, for instance:
 
template<typename... Params_t>
void foo(const Params_t&... params)
{
std::tuple<std::decay_t<std::remove_reference_t<decltype(params)>>...>
values(params...);
}
 
(It also works without std::remove_reference_t, but in that case I think
the tuple will end up with references to the parameters rather than
they values. I suppose it depends on the use case which one is the
better way.)
 
One would think there should be an easier way of doing this.
In other words, one would think it would be possible to use Params_t
directly, rather than the "hack" of using decltype(params).
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: