Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 84743 - c++ segfault with va_arg(marker, float)
Summary: c++ segfault with va_arg(marker, float)
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc3
Version: 8.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-02-20 23:28 UTC by Jim Lindstrom
Modified: 2007-04-18 16:51 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2004-10-03 12:16:07 UTC

Attachments (Terms of Use)

Description Jim Lindstrom 2003-02-20 23:28:17 UTC
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 12:16:07 UTC
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.