From b0c34390cd86b4e32eacad732232aae01eff1a95 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Sat, 27 Sep 2014 20:29:54 +0200 Subject: [PATCH] Fix FP: tmpnam() expects a valid pointer, an uninitialized array (of conforming size) is fine --- cfg/std.cfg | 2 +- test/testuninitvar.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index dee7d8b66..99196138f 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -752,7 +752,7 @@ 0,2:36 false - false + false false false 0:255 false 0:255 diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 666a3a4a5..6e77f7df6 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -3800,6 +3800,17 @@ private: " mbstowcs (wbuf, str, 3);\n" "}"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void foo() {\n" + " char buf[10];\n" + " tmpnam(buf);\n" + "}"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo() {\n" + " char *ptr;\n" + " tmpnam(ptr);\n" + "}"); + TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: ptr\n", "", errout.str()); } void checkDeadPointer(const char code[]) {