[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#469512: Attribute warn_unused_result ignored on function returning union



Package: g++-4.1
Version: 4.1.1-21
Severity: normal

Hi,

I work without execptions and want to ensure that error codes that
might be returned by functions will not be ignored. So I added the
attribute warn_unused_result to the function prototype. But with
functions returning an union the attribute is ignored:

------------------------[ foo.c / foo.cc ]----------------------------
union Error { int error; void* val; };
Error foo(void) __attribute__ ((warn_unused_result));
int bar(void) __attribute__ ((warn_unused_result));
void baz(void) { foo(); bar(); }
----------------------------------------------------------------------
% g++ -W -Wall -O2 -c foo.cc
foo.cc: In function 'void baz()':
foo.cc:4: warning: ignoring return value of 'int bar()', declared with attribute warn_unused_result
----------------------------------------------------------------------
% gcc -W -Wall -O2 -c foo.c 
foo.c: In function 'baz':
foo.c:4: warning: ignoring return value of 'foo', declared with attribute warn_unused_result
foo.c:4: warning: ignoring return value of 'bar', declared with attribute warn_unused_result
----------------------------------------------------------------------

MfG
	Goswin

-- System Information:
Debian Release: lenny/sid
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.22.2-mrvn
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1)

Versions of packages g++-4.1 depends on:
ii  gcc-4.1                     4.1.1-21     The GNU C compiler
ii  gcc-4.1-base                4.1.1-21     The GNU Compiler Collection (base 
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  libstdc++6-4.1-dev          4.1.1-21     The GNU Standard C++ Library v3 (d

g++-4.1 recommends no packages.

-- no debconf information



Reply to: