This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/47749] Wrong function return value


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

--- Comment #6 from Davide Rizzo <elpa.rizzo at gmail dot com> 2011-02-17 09:03:44 UTC ---
The testcase that shows the problem is:

int main(int argc, char **argv)
{
    cout << "fn_bad(true) : " << (fn_bad(true) ? "true" : "false") << endl;
    cout << "fn_bad(false) : " << (fn_bad(false) ? "true" : "false") << endl;
}

The function always returns false, also if the parameter is true.

(In reply to comment #5)
> No, with this testcase it doesn't abort.
> I think the return value is random not only with flag=false (that could be
> acceptable), but also with flag=true.
> I don't use any compiler flag, I tried with -O0, -O1, -O2 and -O3 but I
> didn't notice any difference.
> Unfortunately I cannot try other compiler's versions.
> Comparing the arm assembler listings, in the failing version the statement
> that restores the correct return value in the return register is missing.
> 
> 2011/2/15 rguenth at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
> 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47749
> >
> > --- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org>
> > 2011-02-15 11:18:45 UTC ---
> > does adding
> >
> > extern "C" void abort (void);
> > int main() { if (!fn_bad (true)) abort(); return 0; }
> >
> > cause the testcase to abort at runtime?  Which flags are you using for
> > compiling?
> >
> > --
> > Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> > ------- You are receiving this mail because: -------
> > You reported the bug.
> >


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]