Assuming MyClass uses the default destructor (or no destructor), and this code:
MyClass *buffer = new MyClass[i];
// Construct N objects using placement new
for(size_t i = 0; i < N; i++){
buffer[i].~MyClass();
}
delete[] buffer;
Is there any optimizer that would be able to remove this loop?
Also, is there any way for my code to d...
I'm trying to figure out if
g++ -fsyntax-only
does only syntax checking or if it expands templates too.
Thus, I ask stack overflow for help:
Is there a way to write a program so that syntactically it's valid, but when template expansion is done, an error occurs?
Thanks!
...
Consider the following code:
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
struct A
{
int a;
A(int a_):a(a_) {}
};
int main()
{
vector<auto_ptr<A> > as;
for (int i = 0; i < 10; i++)
{
auto_ptr<A> a(new A(i));
as.push_back(a);
}
for (vector<auto_ptr<A> >::itera...
Please take a look at this code:
template<class T>
class A
{
class base
{
};
class derived : public A<T>::base
{
};
public:
int f(typename A<T>::base& arg = typename A<T>::derived())
{
return 0;
}
};
int main()
{
A<int> a;
a.f();
return 0;
}
Compiling generates the following error message in g++:
test.cpp: In func...
I know that Visual Studio under debugging options will fill memory with a known value.
Does g++ (any version, but gcc 4.1.2 is most interesting) have any options that would
fill an uninitialized local POD structure with recognizable values?
struct something{ int a; int b; };
void foo() {
something uninitialized;
bar(uninitialize...
Hi, I won't post any code, because there is too much that could be relevant. But When I run my program it prints
Internal Bad Op Name!
: Success
Anybody even know what that means? I'm using g++ to compile my code and nowhere in my code do I cout anything even remotely close to something like that. I don't know where it's coming fr...
although it's been said that the support for c++0x new features in g++ are in experimental mode, many gcc developer claimed that you can use most of the new features in your codes and get the program to work.
but when I try to compile this simple program it results in segmentation fault. Why?
#include <thread>
#include <iostream>
void...
As a port, I'd think it'd be hard to keep it completely up to speed with GCC. Is it, or are there any differences with regards to standards compliance or features?
...
I've got the following C++ code :
template <int isBigEndian, typename val>
struct EndiannessConv
{
inline static val fromLittleEndianToHost( val v )
{
union
{
val outVal __attribute__ ((used));
uint8_t bytes[ sizeof( val ) ] __attribute__ ((used));
} ;
outVal = v;
...
I've some C++ projects, which does not use exception handling.
What are the benefits of adding -fno-exceptions , or does gcc figure out itself that I don't use exceptions(nor any libraries that uses exceptions) ?
...
Hi all,
I'm building my program with -pedantic flag, which causes an extra ';' error (because of a third-party header using a few macros inconsistently; the error is not shown when -pedantic is off). I don't really feel like turning -pedantic off, and neither do I want to edit the header. Is there any way to suppress this exact error? L...
Hi all,
I try to compile and link my application in 2 steps :
Compiling:
g++ -c -o file1.o file1.cc general_header.h
g++ -c -o file2.o file2.cc general_header.h
g++ -c -o file3.o file3.cc general_header.h
Linking:
g++ -o myApp file1.o file2.o file3.o
I'm getting a link error as following:
file1.o: file not recog...
hello.
I do some heavy numbercrunching and for me floating-point performance is very important.
I like performance of Intel compiler very much and quite content with quality of assembly it produces.
I am thinking at some point to try C++0x mainly for sugar parts, like auto, initializer list, etc, but also lambdas. at this point I use ...
I am trying to use unicode variable names in g++.
It does not appear to work.
Does g++ not support unicode variable names, ... or is there some subset of unicode (from which I'm not testing in).
Thanks!
...
see title
and some filler text
to deal with the requirement of minimum body text
i hope you're happy now arbitrary limits
...
g++ compiler complains about conversions between related types (from int to enum, from void* to class*, from const char* to unsigned char*, etc.). Compiler handles such convertions as errors and won't compile furthermore. It occurs only when I compile using Dev-C++ IDE, but when I compile the same code (using the compiler which Dev-C++ u...
If I dump the code generated by GCC for a virtual destructor (with -fdump-tree-original), I get something like this:
;; Function virtual Foo::~Foo() (null)
;; enabled by -tree-original
{
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (((struct Foo *) this)->_vptr.Foo = &_ZTV3Foo + 8) >>>
>>;
}
<D.20148>:;
if ((bool) (__in_chrg ...
I've got a compiler error but I can't figure out why.
the .hpp:
#ifndef _CGERADE_HPP
#define _CGERADE_HPP
#include "CVektor.hpp"
#include <string>
class CGerade
{
protected:
CVektor o, rv;
public:
CGerade(CVektor n_o, CVektor n_rv);
CVektor getPoint(float t);
string toString();
};
the .cpp:
#include "CGerade.hp...
Hello,
I'm using precompiled headers on a Qt project to speed up compilation time. I'm using Qt 4.6.2 .When I compile the project using macx-g++ (meaning the g++ compiler) it doesn't include the stdafx.h automatically for each header. When compiling under xcode it will work. I'm using the PRECOMPILED_HEADER qmake constant to point at m...
Can someone show me a simple tail-recursive function in C++?
Why is tail recursion better, if it even is?
What other kinds of recursion are there besides tail recursion?
...