public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48519] New: wrong return-value, with an if () {} after return
@ 2011-04-08 18:25 hilmar.ackermann at googlemail dot com
  2011-04-08 18:32 ` [Bug c++/48519] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: hilmar.ackermann at googlemail dot com @ 2011-04-08 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: wrong return-value, with an if () {} after return
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hilmar.ackermann@googlemail.com


Created attachment 23932
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23932
the *.ii created with -save-temps

Hi,

first my bug is: I have a function with a return, but the function is not
returning the right value, when I write the function like in the example given
at the end of the report. I already asked in a forum of help and they say, in
other c++ compilers it works fine. ;)

you wrote some things to have in an error bug, so I will try to report it
correct, I'm sorry if I did something wrong, but I'm not so good in all this 
..

"the exact version of GCC;
the system type;
the options given when GCC was configured/built;"

the ouput of gcc -v:

"Target: mingw32
Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32
--ena
ble-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls
--disable-win32-regis
try --enable-libgomp --enable-cxx-flags='-fno-function-sections
-fno-data-sectio
ns' --disable-werror --enable-threads --disable-symvers
--enable-version-specifi
c-runtime-libs --enable-fully-dynamic-string --with-pkgversion='TDM-2 mingw32'
-
-enable-sjlj-exceptions --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php
Thread model: win32"

"the complete command line that triggers the bug;"
I'm not sure, I'm using the preconfigured MinGW of Code::Blocks, I think you
mean this command line (?):
mingw32-g++.exe -Wall  -g  -g   -IC:\Programme\wxWidgets-2.8.12\include  -c
"C:\Dateien\projekte\c++ programme\tests\testblub\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -LC:\Programme\wxWidgets-2.8.12\include  -o
bin\Debug\testblub.exe obj\Debug\main.o   
C:\Programme\CodeBlocks\MinGW\lib\OpenAL32.lib
C:\Programme\CodeBlocks\MinGW\lib\alut.lib
C:\Programme\CodeBlocks\MinGW\lib\corona.lib
C:\Programme\CodeBlocks\MinGW\lib\libpangowin32-1.0.dll.a
C:\Programme\CodeBlocks\MinGW\lib\libSDL.dll.a
C:\Programme\CodeBlocks\MinGW\lib\libSDLmain.a

"the compiler output (error messages, warnings, etc.);"
[...]\main.cpp||In function 'int TestFct()':|
[...]\main.cpp|12|warning: control reaches end of non-void function|
||=== Build finished: 0 errors, 1 warnings ===|

"the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a bug
report for the GNAT front end, a complete set of source files (see below)."
the *.ii is attached..

the whole source-code by the way is:

"#include <iostream>
using namespace std;

int test1 = 4;

int TestFct (void)
{
    string test2;                        //if this line will be commented out,
everything works fine
    cout << "abc" << endl;               //if this line will be commented out,
everything works fine
    return 10;
    if (test1 == 3) {}                   //if this line will be commented out,
everything works fine
}

int main(void)
{
    cout << TestFct() << endl;
}
"


regards


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

* [Bug c++/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
@ 2011-04-08 18:32 ` redi at gcc dot gnu.org
  2011-04-08 18:34 ` hilmar.ackermann at googlemail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-08 18:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-08 18:32:28 UTC ---
It prints 10 for me with gcc 4.4.3, what do you see?


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

* [Bug c++/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
  2011-04-08 18:32 ` [Bug c++/48519] " redi at gcc dot gnu.org
@ 2011-04-08 18:34 ` hilmar.ackermann at googlemail dot com
  2011-04-08 18:35 ` hilmar.ackermann at googlemail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hilmar.ackermann at googlemail dot com @ 2011-04-08 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Herbert <hilmar.ackermann at googlemail dot com> 2011-04-08 18:34:31 UTC ---
it prints 206000. maybe the bug is already fixed in a newer version!? Which
version have you?

regards


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

* [Bug c++/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
  2011-04-08 18:32 ` [Bug c++/48519] " redi at gcc dot gnu.org
  2011-04-08 18:34 ` hilmar.ackermann at googlemail dot com
@ 2011-04-08 18:35 ` hilmar.ackermann at googlemail dot com
  2011-04-08 18:36 ` [Bug target/48519] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hilmar.ackermann at googlemail dot com @ 2011-04-08 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Herbert <hilmar.ackermann at googlemail dot com> 2011-04-08 18:35:35 UTC ---
oh, sorry, you already wrote it o.O


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (2 preceding siblings ...)
  2011-04-08 18:35 ` hilmar.ackermann at googlemail dot com
@ 2011-04-08 18:36 ` pinskia at gcc dot gnu.org
  2011-04-08 18:41 ` hilmar.ackermann at googlemail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-04-08 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Target|                            |mingw32
          Component|c++                         |target

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-04-08 18:36:24 UTC ---
It might be a bug in --enable-fully-dynamic-string and/or specific to the
mingw32 target.


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (3 preceding siblings ...)
  2011-04-08 18:36 ` [Bug target/48519] " pinskia at gcc dot gnu.org
@ 2011-04-08 18:41 ` hilmar.ackermann at googlemail dot com
  2011-04-12 11:00 ` ktietz at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hilmar.ackermann at googlemail dot com @ 2011-04-08 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Herbert <hilmar.ackermann at googlemail dot com> 2011-04-08 18:41:35 UTC ---
by the way, I can replace "string test2;" with "vector <int> test2;" as
example, and there is the same bug..


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (4 preceding siblings ...)
  2011-04-08 18:41 ` hilmar.ackermann at googlemail dot com
@ 2011-04-12 11:00 ` ktietz at gcc dot gnu.org
  2011-04-12 13:41 ` hilmar.ackermann at googlemail dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu.org @ 2011-04-12 11:00 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org

--- Comment #6 from Kai Tietz <ktietz at gcc dot gnu.org> 2011-04-12 11:00:19 UTC ---
Hmm, tested it for 32-bit and 64-bit mingw on trunk and for 4.6.x and can't
reproduce the issue.
It shows always:
abc
10

as expected.


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (5 preceding siblings ...)
  2011-04-12 11:00 ` ktietz at gcc dot gnu.org
@ 2011-04-12 13:41 ` hilmar.ackermann at googlemail dot com
  2011-04-12 19:32 ` d.g.gorbachev at gmail dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hilmar.ackermann at googlemail dot com @ 2011-04-12 13:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Herbert <hilmar.ackermann at googlemail dot com> 2011-04-12 13:41:06 UTC ---
Hi,

I don't know why I am the only one with the bug ..? The bug doesn't happen if I
write a second return at the end of the function, so I can solve the problem,
but anyway it's curious.. Maybe someone with the integrated installation of
MinGW in Code::Blocks can test this, perhaps there is a bug, don't know ..  ;)

regards


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (6 preceding siblings ...)
  2011-04-12 13:41 ` hilmar.ackermann at googlemail dot com
@ 2011-04-12 19:32 ` d.g.gorbachev at gmail dot com
  2011-04-12 19:45 ` ktietz at gcc dot gnu.org
  2011-04-13  9:07 ` hilmar.ackermann at googlemail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-04-12 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-04-12 19:32:16 UTC ---
"__Unwind_SjLj_Unregister clobbers return value". I can reproduce it with ver.
4.4.4; works with 4.4.6. See also: PR47490, PR30047 (of which this PR is a
dup).


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (7 preceding siblings ...)
  2011-04-12 19:32 ` d.g.gorbachev at gmail dot com
@ 2011-04-12 19:45 ` ktietz at gcc dot gnu.org
  2011-04-13  9:07 ` hilmar.ackermann at googlemail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu.org @ 2011-04-12 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

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

--- Comment #9 from Kai Tietz <ktietz at gcc dot gnu.org> 2011-04-12 19:45:09 UTC ---
Dup of 47490

*** This bug has been marked as a duplicate of bug 47490 ***


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

* [Bug target/48519] wrong return-value, with an if () {} after return
  2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
                   ` (8 preceding siblings ...)
  2011-04-12 19:45 ` ktietz at gcc dot gnu.org
@ 2011-04-13  9:07 ` hilmar.ackermann at googlemail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: hilmar.ackermann at googlemail dot com @ 2011-04-13  9:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Herbert <hilmar.ackermann at googlemail dot com> 2011-04-13 09:07:04 UTC ---
ah ok, thank you very much, this was the bug ;)

regards


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

end of thread, other threads:[~2011-04-13  9:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-08 18:25 [Bug c++/48519] New: wrong return-value, with an if () {} after return hilmar.ackermann at googlemail dot com
2011-04-08 18:32 ` [Bug c++/48519] " redi at gcc dot gnu.org
2011-04-08 18:34 ` hilmar.ackermann at googlemail dot com
2011-04-08 18:35 ` hilmar.ackermann at googlemail dot com
2011-04-08 18:36 ` [Bug target/48519] " pinskia at gcc dot gnu.org
2011-04-08 18:41 ` hilmar.ackermann at googlemail dot com
2011-04-12 11:00 ` ktietz at gcc dot gnu.org
2011-04-12 13:41 ` hilmar.ackermann at googlemail dot com
2011-04-12 19:32 ` d.g.gorbachev at gmail dot com
2011-04-12 19:45 ` ktietz at gcc dot gnu.org
2011-04-13  9:07 ` hilmar.ackermann at googlemail 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).