the 50- line .c source was compiled on vc++ 6 and ran without any errors (gave needed results) but when compiled on gcc 4.0.1-5mdk i get a wicked logic error! It nearly drove me crazy man! Below are the gcc specs... if u don't understand this bug look at the plaing text source below (its only 50+ lines).
Using built-in specs. Target: i586-mandriva-linux-gnu Configured with: ../configure --prefix=/usr --libexecdir=/usr/lib --with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --enable-languages=c,c++,ada,f95,objc,java --host=i586-mandriva-linux-gnu --with-system-zlib --enable-long-long --enable-__cxa_atexit --enable-clocale=gnu --disable-libunwind-exceptions --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --enable-gtk-cairo --disable-libjava-multilib Thread model: posix /*calculates mathematical constant e raised to the x power */ #include <stdio.h> int main() { short int x = 13, ov_increm = 1, y; double xPCount=0.000000; double fc_cum=1.000000; double k_e=1.000000; /* this already takes care of the first '1' in the formula */ /*this prints the value of variable ov_increm...which gives 1*/ printf("%hd\n", ov_increm); while( x > 12) { printf("Enter a value (<=12, >=1) for which to calculate the exponent: "); scanf("%d",&x); y=x; while ( y <= 0) { printf("Enter a value (<=12, >=1) for which to calculate the exponent: "); scanf("%d",&y); } x=y; } /*note that this variable is initialized in the declaration to 1... but it prints 0 here*/ printf("%hd\n", ov_increm); while( ov_increm <= 12 ) { fc_cum = fc_cum * ov_increm; xPCount=(double)1; y = 1; while( y <= ov_increm ) { xPCount = xPCount * x; y++; } k_e = k_e + (xPCount/fc_cum); ov_increm++; } printf("\nThe value of mathematical constant 'e',\nraised to the power %d is:%20.12f\n\n", x, k_e); return 0; } -- Summary: Nearly drove me crazy! Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jasun202002 at yahoo dot com GCC build triplet: 4.0.1-5mdk for Mandriva Linux release 2006.0 GCC host triplet: gcc version 4.0.1 GCC target triplet: i586-mandriva-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25745