Issue 98128
Summary [Analyzer] False positive uninitialised member when brace initialization used
Labels new issue
Assignees
Reporter dd8
    The following code produces an analyzer warning that member_pointer is garbage or undefined:

```
class One
{
public:
	char* member_pointer = nullptr;
};

class Two
{
public:
	typedef enum
	{
		nameNone = 1,
		nameTwo = 2,
		
	} Name;
	const Name member_name = nameNone;
	One member_one;
};

char* Test()
{
	Two* two = new Two{ Two::nameTwo };
	auto pointer = two->member_one.member_pointer; // reports assigned value is garbage or undefined
	return pointer;
}
```

This looks incorrect because default initialisation is done on any members not initialised by the brace initializer:
https://en.cppreference.com/w/cpp/language/aggregate_initialization#Implicitly_initialized_elements

I've confirmed member_pointer in the code above is initialised to zero when testing with godbolt.org using GCC/CLang/MSVC

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to