Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 84743 - c++ segfault with va_arg(marker, float)
c++ segfault with va_arg(marker, float)
Product: Red Hat Linux
Classification: Retired
Component: gcc3 (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2003-02-20 18:28 EST by Jim Lindstrom
Modified: 2007-04-18 12:51 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-03 08:16:07 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jim Lindstrom 2003-02-20 18:28:17 EST
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


#include <vector>

class MultiPan
	int n_channels;
	MultiPan(int nChans);
	void addEntry(float t, ...);


// 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);
		//total += va_arg(marker, double);
		total += va_arg(marker, float);

	// now actually set the entries
	va_start(marker, t);
		//y_i = va_arg(marker, double);
		y_i = va_arg(marker, float);
		//(InterpList[i])->addEntry(t, y_i/total);


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.
Comment 1 Richard Henderson 2004-10-03 08:16:07 EDT
ICE fixed with gcc 3.3.2-1.

Note You need to log in before you can comment on or make changes to this bug.