Skip to content

<valarray>: slice_array's copy ctor is missing, the same with mask_array, gslice_array, indirect_array #940

@AlexGuteniev

Description

@AlexGuteniev

Describe the bug
slice_array's copy constructor and assignment operator are missing

Command-line test case

d:\Temp2>type repro.cpp
#include <valarray>
#include <cassert>

int main()
{
        int a1[] = { 0, 1, 2 };
        std::valarray<int> v1(a1, 3);
        std::slice_array<int> s1 = v1[std::slice(1, 1, 1)];
        std::slice_array<int> s2 = v1[std::slice(0, 1, 1)];
        std::slice_array<int> const& s3 = s1 = s2;
        std::slice_array<int> s4 = s3;
        assert(&s1 == &s3);
        assert(&s1 == &s4);
}

d:\Temp2>cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cpp
Microsoft (R) Incremental Linker Version 14.27.29009.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:repro.exe
repro.obj
repro.obj : error LNK2019: unresolved external symbol "public: __thiscall std::slice_array<int>::slice_array<int>(class std::slice_array<int> const &)" (??0?$slice_array@H@std@@QAE@ABV01@@Z) referenced in function _main
repro.obj : error LNK2019: unresolved external symbol "public: class std::slice_array<int> & __thiscall std::slice_array<int>::operator=(class std::slice_array<int> const &)" (??4?$slice_array@H@std@@QAEAAV01@ABV01@@Z) referenced in function _main
repro.exe : fatal error LNK1120: 2 unresolved externals

Expected behavior
Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1

Additional context
The operators are intentionally not defined.

STL/stl/inc/valarray

Lines 941 to 943 in 3f6c715

slice_array(const slice_array&); // not defined
slice_array& operator=(const slice_array&); // not defined

According to cppreference, both copy constructor and assignment operator should be defined.

It confirms with [template.slice.array.overview]

This item is also tracked on Developer Community as DevCom-1075574 and by Microsoft-internal VSO-109266 / AB#109266.

The same problem is tracked on Developer Community as DevCom-246260 and by Microsoft-internal VSO-366115 / AB#366115.

The same problem with mask_array is tracked on Developer Community as DevCom-1075573.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!high priorityImportant!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions