[cfe-dev] -O4 with #include <iostream>
Toralf Niebuhr
niebuhr at niebuhrt.de
Sun Jul 4 02:47:10 PDT 2010
I recently asked why something doesn't compile. With the latest trunk it compiles fine under some conditions.
// ---- Out.h
class Out {
public:
void out();
};
// ---- Out.cpp
#include "Out.h"
#include <iostream>
void Out::out() {
std::cout << "Hello World" << std::endl;
}
// ---- main.cpp
#include "Out.h"
int main() {
Out o;
o.out();
return 0;
}
compiling this with
clang++ -O4 -o main main.cpp Out.cpp
gives the following error
Alloca array size must be i32
%o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
Instruction does not dominate all uses!
%o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
call void @_ZN3Out3outEv(%class.Out* %o)
Broken module found, compilation aborted!
Stack dump:
0. Running pass 'Function Pass Manager' on module 'ld-temp.o'.
1. Running pass 'Module Verifier' on function '@main'
The interesting thing is the following
if I modify main.cpp to
// ---- main.cpp
#include "Out.h"
#include <iostream>
int main() {
Out o;
o.out();
return 0;
}
It compiles fine and the binary runes fine too.
This makes me think that there was to much optimization done during compile time when compiling Out.cpp
Any ideas?
Toralf
More information about the cfe-dev
mailing list