Hello, yes, i have tried -O , -O1 , -O2, -O3 and no warning is raised by g++. Best regards Martin -------- Original-Nachricht -------- > Datum: Sun, 21 Jun 2009 08:34:50 -0400 > Von: John Fine <johnsfine@xxxxxxxxxxx> > An: Martin Ettl <ettl.martin@xxxxxx> > CC: gcc-help@xxxxxxxxxxx > Betreff: Re: why does g++ not warn about division by zero? > Have you tried that at various optimization levels? > > At lower optimization levels, the "inline" keyword should not cause the > function to actually get inlined. > > If the function is not actually inlined, gcc cannot be aware of the > divide by zero. > > I don't happen to know whether gcc would warn if it were aware of the > divide by zero, nor if actually inlining is sufficient to make it > aware. I'm just saying actually inlining should be necessary to make it > aware of the divide by zero. > > Martin Ettl wrote: > > template <typename T1, typename T2> inline T1 foo (T1 const& a, T2 > const& b) > > { > > // .... > > return a/b; > > } > > > > int main() > > { > > std::cout << foo(4.,0) << std::endl; > > return 0; > > } > > > > I compiled the testprogramm with following command: > > g++ -W -Wall -pedantic -o test test.cpp > > -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01