public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59709] New: break program behavior with optimization
@ 2014-01-07  7:01 faithandbrave at gmail dot com
  2014-01-07  7:03 ` [Bug c++/59709] " faithandbrave at gmail dot com
  2014-01-08  4:47 ` faithandbrave at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: faithandbrave at gmail dot com @ 2014-01-07  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59709
           Summary: break program behavior with optimization
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: faithandbrave at gmail dot com

Hi, I encountered difficult problem. If I use -O2 option, follow code behavior
be break. (in GCC 4.8.2)

#include <iostream>
#include <string>
#include <boost/spirit/include/qi.hpp>

namespace qi = boost::spirit::qi;

int main()
{
    const std::string input = "hello:";

    auto rule = *(qi::char_ - ':') >> ':';

    std::string::const_iterator it = input.begin();
    std::string result;
    if (qi::parse(it, input.end(), rule, result)) {
        std::cout << "parse successful" << std::endl;
    }
    else {
        std::cout << "parse failed" << std::endl;
    }
}

If I don't use optimization, the problem result is "parse successful". But if I
use optimization, the problem result is output "parse failed" or output
nothing.

If I don't use `auto` and I write type, the problem result is "parse
successful" correctly :

#include <iostream>
#include <string>
#include <boost/spirit/include/qi.hpp>

namespace qi = boost::spirit::qi;

int main()
{
    const std::string input = "hello:";

    qi::rule<std::string::const_iterator, std::string()> rule = *(qi::char_ -
':') >> ':';

    std::string::const_iterator it = input.begin();
    std::string result;
    if (qi::parse(it, input.end(), rule, result)) {
        std::cout << "parse successful" << std::endl;
    }
    else {
        std::cout << "parse failed" << std::endl;
    }
}

I couldn't write minimal code without Boost.Spirit. Sorry.


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

* [Bug c++/59709] break program behavior with optimization
  2014-01-07  7:01 [Bug c++/59709] New: break program behavior with optimization faithandbrave at gmail dot com
@ 2014-01-07  7:03 ` faithandbrave at gmail dot com
  2014-01-08  4:47 ` faithandbrave at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: faithandbrave at gmail dot com @ 2014-01-07  7:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Akira Takahashi <faithandbrave at gmail dot com> ---
Boost version is 1.55.0.


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

* [Bug c++/59709] break program behavior with optimization
  2014-01-07  7:01 [Bug c++/59709] New: break program behavior with optimization faithandbrave at gmail dot com
  2014-01-07  7:03 ` [Bug c++/59709] " faithandbrave at gmail dot com
@ 2014-01-08  4:47 ` faithandbrave at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: faithandbrave at gmail dot com @ 2014-01-08  4:47 UTC (permalink / raw)
  To: gcc-bugs

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

Akira Takahashi <faithandbrave at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Akira Takahashi <faithandbrave at gmail dot com> ---
http://stackoverflow.com/questions/20763665/boost-spirit-v2-qi-bug-associated-with-optimization-level

Sorry, this is Boost.Spirit's issue. not optimization issue.


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

end of thread, other threads:[~2014-01-08  4:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07  7:01 [Bug c++/59709] New: break program behavior with optimization faithandbrave at gmail dot com
2014-01-07  7:03 ` [Bug c++/59709] " faithandbrave at gmail dot com
2014-01-08  4:47 ` faithandbrave at gmail 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).