Description of problem: I'm trying to use a variable number of float args in a class member function. I've deleted all the file components that aren't central to the bug, leaving only a minimal set of code. gcc (invoked by 'c++') complains that the float should be promoted to a double, and then segfaults at the end of the procedure. Version-Release number of selected component (if applicable): [jlindstr@herbert temp]$ gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) How reproducible: Every single time Steps to Reproduce: 1. Setup these two files in the same directory //----------------------------------------------------------------------------// // MultiPan.h //----------------------------------------------------------------------------// #ifndef MOSS_MULTIPAN_H #define MOSS_MULTIPAN_H #include <vector> class MultiPan { private: int n_channels; public: MultiPan(int nChans); void addEntry(float t, ...); }; #endif //MOSS_MULTIPAN_H //----------------------------------------------------------------------------// // MultiPan.cpp //----------------------------------------------------------------------------// #include <cstdarg> #include "MultiPan.h" MultiPan::MultiPan(int nChans) { n_channels = nChans; } void MultiPan::addEntry(float t, ...) { va_list marker; int i; float y_i, total; // total the params va_start(marker, t); for(i=0;i<n_channels;i++) //total += va_arg(marker, double); total += va_arg(marker, float); va_end(marker); // now actually set the entries va_start(marker, t); for(i=0;i<n_channels;i++) { //y_i = va_arg(marker, double); y_i = va_arg(marker, float); //(InterpList[i])->addEntry(t, y_i/total); } va_end(marker); } //----------------------------------------------------------------------------// 2. invoke the compiler: c++ -O2 -ftemplate-depth-25 -c MultiPan.cpp -o MultiPan.o Actual results: MultiPan.cpp: In member function `void MultiPan::addEntry(float, ...)': MultiPan.cpp:21: warning: `float' is promoted to `double' when passed through `...' MultiPan.cpp:21: warning: (so you should pass `double' not `float' to `va_arg') MultiPan.cpp:29: warning: `float' is promoted to `double' when passed through `...' MultiPan.cpp:33: internal error: Segmentation fault Please submit a full bug report, [...] Expected results: Normal compilation Additional info: When I call va_arg with 'double' instead of 'float' (leaving the function prototype as is), everything then works fine.
ICE fixed with gcc 3.3.2-1.