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: unassig...@gcc.gnu.org
        ReportedBy: hilmar.ackerm...@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

Reply via email to