public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function
@ 2012-10-22  2:10 julien.nitard at m4tp dot org
  2012-10-22  2:14 ` [Bug c++/55015] " julien.nitard at m4tp dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: julien.nitard at m4tp dot org @ 2012-10-22  2:10 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015

             Bug #: 55015
           Summary: Lambda functions not found at link time when declared
                    in an inline function
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: julien.nitard@m4tp.org


Hi all,

Following this stackoverflow question
http://stackoverflow.com/questions/13003941/lambda-not-found-when-defined-in-an-inline-function-in-g-4-7,
I was directed here to report a bug.
I have tried to find similar bugs but haven't.

Lambdas are not handled properly when declared inside inline functions (or so
it seems).

Here is a LWS link that demonstrates the error:
http://liveworkspace.org/code/35374b3c9b0d40e8ccc0819eb44d7f9e


In case the link disappears, here the source:

#include <stdexcept>
#include <string>

#include <boost/algorithm/string.hpp>

using std::string;

typedef bool (*FieldComparer)(const std::string&, const std::string&);

inline FieldComparer
GetComparer(const std::string& query, string& separator)
{
    if (query.find('=') != std::string::npos) {
        separator = "=";
        return [](const string& s1, const string& s2) { return s1 == s2; };
    }
    else if (query.find('^') != string::npos) {
        separator = "^";
        return [](const string& s1, const string& s2) { return
boost::starts_with(s1, s2); };
    }
    else if (query.find('*') != string::npos) {
        separator = "*";
        return [](const string& s1, const string& s2) { return
boost::contains(s1, s2); };
    }
    else if (query.find('!') != string::npos) {
        separator = "!";
        return [](const string& s1, const string& s2) { return s1 != s2; };
    }
    else
        throw std::invalid_argument("Search: could not find operator in query
string.");
}

int main()
{
  std::string sep;
  auto comp = GetComparer( "=", sep );
}

Many thanks,


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

end of thread, other threads:[~2012-12-06 15:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-22  2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
2012-10-22  2:14 ` [Bug c++/55015] " julien.nitard at m4tp dot org
2012-10-22  5:02 ` spam_hole at shaw dot ca
2012-10-22  5:09 ` pinskia at gcc dot gnu.org
2012-11-02 11:11 ` paolo.carlini at oracle dot com
2012-11-26 23:38 ` [Bug c++/55015] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
2012-11-27 10:26 ` paolo.carlini at oracle dot com
2012-11-27 11:01 ` jakub at gcc dot gnu.org
2012-11-27 11:03 ` paolo.carlini at oracle dot com
2012-11-27 11:04 ` paolo.carlini at oracle dot com
2012-12-03 16:01 ` rguenth at gcc dot gnu.org
2012-12-05 22:35 ` jason at gcc dot gnu.org
2012-12-06 11:32 ` paolo.carlini at oracle dot com
2012-12-06 14:38 ` jason at gcc dot gnu.org
2012-12-06 14:40 ` jason at gcc dot gnu.org
2012-12-06 14:43 ` jason at gcc dot gnu.org
2012-12-06 15:45 ` paolo.carlini at oracle dot com

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).