public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -fanalyzer triggers on empty vector of strings and foreach loop
@ 2020-05-01 21:57 andre maute
  2020-05-02 11:24 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: andre maute @ 2020-05-01 21:57 UTC (permalink / raw)
  To: gcc-help

I wonder if this is expected behavior

this is on a recent fedora 32 x86_64 system

g++ (GCC) 10.0.1 20200328 (Red Hat 10.0.1-0.11)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To trigger a lengthy list of deductions, I use the following three files and
g++ -fanalyzer main.cpp line.cpp

Using only the given warning flag triggers nothing
g++ -Wanalyzer-null-dereference main.cpp line.cpp

///// begin of main.cpp ///////////
#include <string>
#include <vector>

#include "line.h"

int main()
{
	std::vector<std::string> m_Text;
	std::vector<Line> m_Lines;

	for( const auto& line : m_Text ) {
		m_Lines.emplace_back(line);
	}

	return 0;
}
///// end of main.cpp /////////////

///// begin of line.h ///////////
#ifndef LINE_H
#define LINE_H

#include <string>

class Line
{
public:
	explicit
	Line(
		const std::string& data
	);

	const std::string& data() const;

private:
	std::string m_Data;
};

#endif /* LINE_H */
///// end of line.h /////////////

///// begin of line.cpp ///////////
#include "line.h"

Line::Line(
	const std::string& data
)
: m_Data(data)
{}

const std::string&
Line::data() const
{
	return m_Data;
}
///// end of line.cpp /////////////

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-06 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 21:57 -fanalyzer triggers on empty vector of strings and foreach loop andre maute
2020-05-02 11:24 ` Jonathan Wakely
2020-05-02 17:18   ` andre maute
2020-05-06 16:43     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).