ConnectNamedPipe() function triggering "Debug Error! abort()" upon execution

  abort, c++, c++17, named-pipes, visual-studio

The below part of my code consistently triggers a "Debug Error! abort() has been called" message upon execution in Visual Studio:

if(m_handle==INVALID_HANDLE_VALUE) return(false); // no return here, therefore m_handle is valid (?)
if(!m_connected){ // some bool indicating a connection doesn't already exist

    if(ConnectNamedPipe(m_handle,NULL)==0){ // --- Abort() message triggered here ----
        // blah

The m_handle variable had already (and seemingly successfully) been created via:

if(!pipename || *pipename==0) return(false); // no return here. pipeName is a correctly initialized LPTSTR variable

   m_handle = CreateNamedPipe(pipename,PIPE_ACCESS_DUPLEX,
                            PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,

   if(m_handle==INVALID_HANDLE_VALUE){ // produces if(false)
      wprintf(L"Creating pipe '%s' failedn",pipename);

After investigating the issue, it is not clear what’s going wrong here, since the abort() feedback is sparse.

Any solutions?

Source: Windows Questions C++