The latest release in the 3.4 release series is GCC 3.4.3.
GCC 3.4 has many improvements in the C++ frontend. Before reporting a bug, please make sure it's really GCC, and not your code, that is broken.
-nostdinc the preprocessor used to ignore
both standard include paths and include paths
contained in environment variables. It was neither documented
nor intended that environment variable paths be ignored, so
this has been corrected.-fvolatile,
-fvolatile-global and -fvolatile-static.
It is unlikely that they worked correctly in any 3.x release.<varargs.h>. Use
<stdarg.h> instead.accum. This register
has been removed.--enable-threads=pthreads has
been removed; use --enable-threads=posix instead,
which should have the same effect.-finline-insns,
--param max-inline-insns-single
and --param max-inline-insns-auto need to be
reconsidered.--param max-inline-slope
and --param min-inline-insns
have been removed; they are not needed for the new bottom-up inlining
heuristics.asm statements are emitted may have changed. Code
relying on some particular ordering needs to be updated. The
majority of such top-level asm statements can be replaced by section
attributes.asm
statement refers to the variable/function directly. In that
case either the variable/function shall be listed in asm statement
operand or in the case of top-level asm statements the attribute
used shall be used to force function/variable to be
always output and considered as a possibly used by unknown code.
For variables the attribute is accepted only by GCC 3.4 and newer,
while for earlier versions it is sufficient to use
unused to silence warnings about the variables not being
referenced.
To keep code portable across different GCC versions, you can use
appropriate preprocessor conditionals.
asm statements calling functions directly. Again
the attribute used shall be used to prevent this
behavior.-fno-unit-at-a-time can be used,
but this scheme may not be supported by future releases of GCC.
.bss section on some operating systems.
Versions of GNU Emacs up to (and including) 21.3 will not work
correctly when using this optimization; you can use
-fno-zero-initialized-in-bss to disable it.--enable-threads=posix
(the default on most targets that support pthreads) then
_REENTRANT will be defined unconditionally by
some libstdc++ headers. C++ code which relies on that macro to
detect whether multi-threaded code is being compiled might
change in meaning, possibly resulting in linker errors for
single-threaded programs.
Affected users of Boost should
compile single-threaded code with -DBOOST_DISABLE_THREADS.
See Bugzilla for
more
information.
fork() calls and parallel
runs of profiled programs.gcov coverage tool has been improved.make profiledbootstrap available to build a faster
compiler.
Experiments made on i386 hardware showed an 11% speedup on
-O0 and a 7.5% speedup on -O2 compilation of a
large C++
testcase.
-fprofile-values-fvpt
aims to optimize some code sequences by exploiting knowledge about
value ranges or other properties of the operands. At the moment a
conversion of expensive divisions into cheaper operations has been
implemented.-fprofile-generate and -fprofile-use
command line options to simplify the use of profile feedback.-funit-at-a-time (and implied by
-O2). In this scheme a whole file is parsed first and
optimized later. The following basic inter-procedural optimizations
are implemented:
--param
inline-unit-growth).--param large-function-insns
and --param large-function-growth.-funroll-loops,
-fpeel-loops and -funswitch-loops flags,
respectively).
The old loop unroller still can be enabled by
-fold-unroll-loops and may produce better code in some
cases, especially when the webizer optimization pass is not
run.
-fweb (and implied
by -O3) improves the quality of register allocation, CSE,
first scheduling pass and some other optimization passes by avoiding
re-use of pseudo registers with non-overlapping live ranges. The pass
almost always improves code quality but does make debugging difficult
and thus is not enabled by default by -O2
The pass is especially effective as cleanup after code duplication passes, such as the loop unroller or the tracer.
-fsched2-use-superblocks and
-fsched2-use-traces, respectively.GNAT.Sockets,
GNAT.OS_Lib, GNAT.Debug_Pools, ... GNAT.xxxx packages (e.g. GNAT.Strings,
GNAT.Exception_Action) -gnatS switch replacing gnatpsta#import and
#pragma once.
These two directives have therefore been un-deprecated.
int i;
(char) i = 5;
or this:
char *p;
((int *) p)++;
is no longer accepted for C++ and will not be accepted for C and Objective-C in a future version.
int a, b, c;
(a ? b : c) = 2;
will not be accepted for C and Objective-C in a future version.
int a, b;
(a, b) = 2;
will not be accepted for C and Objective-C in a future version. A possible non-intrusive workaround is the following:
(*(a, &b)) = 2;
__builtin_popcount
for counting bits, finding the highest and lowest bit in a
word, and parity have been added.-fwritable-strings option has been deprecated
and will be removed.-finput-charset command
line option. In the future we will add support for inline encoding
markers.typename and
template keywords to disambiguate dependent names,
as required by the C++ standard.
struct K {
typedef int mytype_t;
};
template <class T1> struct A {
template <class T2> struct B {
void callme(void);
};
template <int N> void bar(void)
{
// Use 'typename' to tell the parser that T1::mytype_t names
// a type. This is needed because the name is dependent (in
// this case, on template parameter T1).
typename T1::mytype_t x;
x = 0;
}
};
template <class T> void template_func(void)
{
// Use 'template' to prefix member templates within
// dependent types (a has type A<T>, which depends on
// the template parameter T).
A<T> a;
a.template bar<0>();
// Use 'template' to tell the parser that B is a nested
// template class (dependent on template parameter T), and
// 'typename' because the whole A<T>::B<int> is
// the name of a type (again, dependent).
typename A<T>::template B<int> b;
b.callme();
}
void non_template_func(void)
{
// Outside of any template class or function, no names can be
// dependent, so the use of the keyword 'typename' and 'template'
// is not needed (and actually forbidden).
A<K> a;
a.bar<0>();
A<K>::B<float> b;
b.callme();
}
template <typename T> struct B {
int m;
int n;
int f ();
int g ();
};
int n;
int g ();
template <typename T> struct C : B<T> {
void h ()
{
m = 0; // error
f (); // error
n = 0; // ::n is modified
g (); // ::g is called
}
};
You must make the names dependent, e.g. by prefixing them
with this->. Here is the corrected definition
of C<T>::h,
template <typename T> void C<T>::h ()
{
this->m = 0;
this->f ();
this->n = 0
this->g ();
}
As an alternative solution, you may use using
declarations instead of this->:
template <typename T> struct C : B<T> {
using B<T>::m;
using B<T>::f;
using B<T>::n;
using B<T>::g;
void h ()
{
m = 0;
f ();
n = 0;
g ();
}
};
void foo(int);
template <int> struct A {
static void bar(void){
foo('a');
}
};
void foo(char);
int main()
{
A<0>::bar(); // Calls foo(int), used to call foo(char).
}
class or struct before the template-id:
template <int N>
class A {};
template A<0>; // error, not accepted anymore
template class A<0>; // OK
namespace N {}; // Invalid semicolon.
void f() {}; // Invalid semicolon.
X x(1) __attribute__((...));
is no longer accepted. Instead, use:
X x __attribute__((...)) (1);
template <template <class> class TT> class X {};
template <class T> class Y {
X<Y> x; // Invalid, Y is always a type template parameter.
};
The valid code for the above example is
X< ::Y> x; // Valid.
(Notice the space between < and : to
prevent GCC to interpret this as a digraph for
[.)
template <typename T>
class C {
friend void f<> (C&);
};
is rejected. You must first declare f as a
template,
template <typename T> void f(T);
private class members,
for example. See the ISO C++ Standard Committee's defect
report #209 for details.
template <typename T> struct A {
void f();
};
class C {
template <typename T> friend void A<T>::f();
};template <> to introduce template
specializations, as required by the standard. For example,
template <typename T>
struct S;
struct S<int> { };
is rejected. You must write,
template <> struct S<int> {};
struct S {
int h();
void f(int i = g());
int g(int i = h());
};
This behavior is not mandated by the standard. Now G++ issues
an error about this code. To avoid the error, you must move
the declaration of g before the declaration of
f. The default arguments for g must
be visible at the point where it is called.
__cxa_vec_new2 and
__cxa_vec_new3 were changed to return
NULL when the allocator argument returns
NULL. These changes are incorporated into the
libstdc++ runtime library.
class A;
typedef A B;
class C {
friend class B; // error, no typedef name here
friend B; // error, friend always needs class/struct/enum
friend class A; // OK
};
template <int> class Q {};
typedef Q<0> R;
template class R; // error, no typedef name here
template class Q<0>; // OKint* a = new (int)[10]; // error, not accepted anymore int* a = new int[10]; // OK
class A
{
public:
A();
private:
A(const A&); // private copy ctor
};
A makeA(void);
void foo(const A&);
void bar(void)
{
foo(A()); // error, copy ctor is not accessible
foo(makeA()); // error, copy ctor is not accessible
A a1;
foo(a1); // OK, a1 is a lvalue
}
This might be surprising at first sight, especially since most popular compilers do not correctly implement this rule (further details).
class A
{
public:
void pub_func();
protected:
void prot_func();
private:
void priv_func();
};
class B : public A
{
public:
void foo()
{
&A::pub_func; // OK, pub_func is accessible through A
&A::prot_func; // error, cannot access prot_func through A
&A::priv_func; // error, cannot access priv_func through A
&B::pub_func; // OK, pub_func is accessible through B
&B::prot_func; // OK, can access prot_func through B (within B)
&B::priv_func; // error, cannot access priv_func through B
}
};streambuf, filebuf, separate
synched with C Standard I/O streambuf.filebuf work
(UTF-8, Unicode).wchar_t specializations on Mac OS 10.3.x,
FreeBSD 5.x, Solaris 2.7 and above, AIX 5.x, Irix 6.5.__cxa_demangle with support for C++ style
allocators.@try... @catch...
@finally, @throw) and synchronization
(@synchronized) support. These are accessible via
the -fobjc-exceptions switch; as of this writing,
they may only be used in conjunction with -fnext-runtime
on Mac OS X 10.3 and later. See Options Controlling Objective-C Dialect for more
information.@encode logic. The C99 _Bool
and C++ bool type may now be encoded as
'B'. In addition, the back-end/codegen dependencies
have been removed.-fzero-link) and
"Fix-and-Continue" (-freplace-objc-classes) debugging
modes, currently available on Mac OS X 10.3 and later. See Options Controlling Objective-C Dialect for more
information.-fno-nil-receivers
) on the assumption that message receivers are never
nil. This is currently available on Mac OS X 10.3 and
later. See Options Controlling Objective-C Dialect for more
information.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizing the more
obscure instructions of the CPU.arm-elf configuration has been converted to use
the new code.-mcpu=iwmmxt command
line switch.arm-wince-pe. This is
similar to the arm-pe target, but it defaults to using the
APCS32 ABI.-mcpu=ep9312 command line switch. Note however that
the multilibs to support this chip are currently disabled in
gcc/config/arm/t-arm-elf, so if you want to enable their
production you will have to uncomment the entries in that
file.long long has been added.saveall attribute has been added.-march=k8 and -mcpu=k8.-m128bit-long-double is now less buggy.__float128 support in 64-bit compilation.-mcpu has been renamed to -mtune.-mtune=itanium2) is enabled by default now. To
generate code tuned for Itanium 1 the option
-mtune=itanium1 should be used.m68k-uclinux target, based on former work done
by Paul Dale (SnapGear Inc.). Code generation for the
ColdFire processors family has been enhanced and extended
to support the MCF 53xx and MCF 54xx cores, integrating
former work done by Peter Barada (Motorola).-march compiler option
and should work with any MIPS I (mips-*) or MIPS III
(mips64-*) configuration.-march=mips32r2.-mfix-sb1, to work around
certain SB-1 errata.--with-arch, which specifies the default
value of the -march option.--with-tune, which specifies the default
value of the -mtune option.--with-abi, which specifies the default ABI.--with-float=soft, which tells GCC to
use software floating point by default.--with-float=hard, which tells GCC to
use hardware floating point by default.gcjlib URL type; this
lets URLClassLoader load code from shared
libraries.gij.java.nio have been implemented.
Direct and indirect buffers work, as do fundamental file and
socket operations.java.awt has been improved, though it is still
not ready for general use.Runtime.exec() handling and support for accented
characters in filenames.__builtin_alpha_zap to allow utilizin