Skip to content

Commit 7c095f2

Browse files
Fix #12748 FP arithOperationsOnVoidPointer with unique_ptr to array (#6420)
1 parent e2f340f commit 7c095f2

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

cfg/std.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8655,19 +8655,16 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
86558655
<use-retval/>
86568656
<leak-ignore/>
86578657
<noreturn>false</noreturn>
8658-
<returnValue type="void *"/>
86598658
</function>
86608659
<function name="std::auto_ptr::reset,std::shared_ptr::reset,std::unique_ptr::reset,std::weak_ptr::reset">
86618660
<noreturn>false</noreturn>
86628661
<arg nr="1" direction="in" default="0">
86638662
<not-uninit/>
86648663
</arg>
8665-
<returnValue type="void *"/>
86668664
</function>
86678665
<function name="std::auto_ptr::release,std::unique_ptr::release">
86688666
<use-retval/>
86698667
<noreturn>false</noreturn>
8670-
<returnValue type="void *"/>
86718668
</function>
86728669
<function name="std::tie">
86738670
<noreturn>false</noreturn>

test/cfg/std.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4948,6 +4948,12 @@ void smartPtr_get2(std::vector<std::unique_ptr<int>>& v)
49484948
}
49494949
}
49504950

4951+
bool smartPtr_get3(size_t n, size_t i) { // #12748
4952+
std::unique_ptr<int[]> buf = std::make_unique<int[]>(n);
4953+
const int* p = buf.get() + i;
4954+
return p != nullptr;
4955+
}
4956+
49514957
void smartPtr_reset()
49524958
{
49534959
std::unique_ptr<int> p(new int());

test/testautovariables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3073,7 +3073,7 @@ class TestAutoVariables : public TestFixture {
30733073
" return ptr.get();\n"
30743074
"}\n");
30753075
ASSERT_EQUALS(
3076-
"[test.cpp:4] -> [test.cpp:3] -> [test.cpp:4]: (error) Returning pointer to local variable 'ptr' that will be invalid when returning.\n",
3076+
"[test.cpp:4] -> [test.cpp:3] -> [test.cpp:4]: (error) Returning object that points to local variable 'ptr' that will be invalid when returning.\n",
30773077
errout_str());
30783078

30793079
// #12600

0 commit comments

Comments
 (0)