From: andre maute <andre.maute@gmx.de>
To: gcc-help@gcc.gnu.org
Subject: -fanalyzer triggers on empty vector of strings and foreach loop
Date: Fri, 1 May 2020 23:57:02 +0200 [thread overview]
Message-ID: <85dcd761-ff53-3c38-06c5-538af59bc744@gmx.de> (raw)
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 /////////////
next reply other threads:[~2020-05-01 21:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 21:57 andre maute [this message]
2020-05-02 11:24 ` Jonathan Wakely
2020-05-02 17:18 ` andre maute
2020-05-06 16:43 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85dcd761-ff53-3c38-06c5-538af59bc744@gmx.de \
--to=andre.maute@gmx.de \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).