FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian GCC

LinkBack Thread Tools
Old 11-18-2010, 10:54 PM
Tom Fogal
Default Bug#603979: g++-4.3: #pragma pack mechanism receives less error checking than attribute method

Package: g++-4.3
Version: 4.3.2-1.1
Severity: normal

As documented here:


g++ supports using the #pragma pack syntax to forcibly pack a structure
which must be the minimum size. The alternative mechanism to specify
this is to add `__attribute__((packed))' before the final terminating
semicolon of the struct definition.

Unfortunately it seems the path for checking errors is not uniform
between the two mechanisms. The compiler complains about the
definition of struct Y (returning a reference to a field in a packed
struct is invalid) in the following program, but not the definition of
struct X.

#include <cstdlib>
#pragma pack(push, 1)
struct X {
int x;
int& operator[](size_t) { return this->x; }
#pragma pack(pop)

struct Y {
int x;
int& operator[](size_t) { return this->x; }
} __attribute__((packed));

If these paths are truly doing the same thing, the error message should
also apply to the first struct's definition. The exact error text is:

pack.cxx: In member function ‘int& Y:perator[](size_t)’:
pack.cxx:11: error: cannot bind packed field ‘((Y*)this)->Y::x’ to

-- System Information:
Debian Release: 5.0.6
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages g++-4.3 depends on:
ii gcc-4.3 4.3.2-1.1 The GNU C compiler
ii gcc-4.3-base 4.3.2-1.1 The GNU Compiler Collection (base
ii libc6 2.7-18lenny4 GNU C Library: Shared libraries
ii libgmp3c2 2:4.2.2+dfsg-3 Multiprecision arithmetic library
ii libmpfr1ldbl 2.3.1.dfsg.1-2 multiple precision floating-point
ii libstdc++6-4.3-dev 4.3.2-1.1 The GNU Standard C++ Library v3 (d

g++-4.3 recommends no packages.

Versions of packages g++-4.3 suggests:
pn g++-4.3-multilib <none> (no description available)
ii gcc-4.3-doc 4.3.2.nf1-1 documentation for the GNU compiler
pn libstdc++6-4.3-dbg <none> (no description available)

-- no debconf information

To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20101118235450.7934.76406.reportbug@shigeru.sci.ut ah.edu">http://lists.debian.org/20101118235450.7934.76406.reportbug@shigeru.sci.ut ah.edu

Thread Tools

All times are GMT. The time now is 11:21 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org