compiler-bug

Possible Java compiler bug! Program does not compile with some compilers

ぃ、小莉子 提交于 2019-12-01 03:50:12
问题 First, a little background (or skip down a little if not interested). I'm irritated and confused! This should be a pretty simple use case, and indeed my code has been compiling just fine with the Eclipse JDT compiler, so until now I've been configuring Maven to make sure to do this. It's been bothering me too much though that it doesn't compile with the Oracle JDK and OpenJDK, as I thought it may actually have been a problem with my code, so I've looked into it again. I thought perhaps that

Are explicit conversion operators allowed in braced initializer lists?

孤街浪徒 提交于 2019-12-01 02:41:41
The following code compiles with GCC 4.9.2 but not with Clang 3.5.0: #include <string> class Foo { public: explicit operator std::string() const; }; std::string bar{Foo{}}; // Works in g++, fails in clang++ std::string baz(Foo{}); // Works in both clang++ says: foo.cpp:9:13: error: no matching constructor for initialization of 'std::string' (aka 'basic_string<char>') std::string bar{Foo{}}; ^ ~~~~~~~ ...: note: candidate constructor not viable: no known conversion from 'Foo' to 'const std::basic_string<char> &' for 1st argument basic_string(const basic_string& __str); ^ Curiously, it works if

“this” captured by lambda is incorrect. GCC compiler bug?

我是研究僧i 提交于 2019-11-30 17:30:20
For the last few days, I have been debugging a weird issue involving lambdas in C++. I have reduced the problem down to the following symptoms: The this pointer gets corrupted inside a lambda (note: this is always captured by copy, so the lambda should get its own this pointer, which points to the App object) It only occurs if a std::cout print statement is present , and called before the lambda is created. The print statement can be seemingly completely unrelated (e.g. print "Hello!"). printf() also exhibits the same behaviour. It only occurs when cross-compiling. It compiles and runs fine

Possible compiler bug in Visual C++ 2012 (x86)?

做~自己de王妃 提交于 2019-11-30 16:53:13
I'm currently experiencing random floating point errors when compiling for x86 targets using VC++ 11 (CTP Update 1) . See the short example "test.cpp" below, and compile using: cl /GL /O2 /EHsc test.cpp /link /MACHINE:X86 The output should be 10 == 10 , but it produces 10 == 0 when /GL (whole program optimization) is enabled. The problem seems to be that get_scaling_factor() pushes the result on the floating point stack, but the calling function is expecting it in the SSE register XMM0 . Question : am I missing something obvious, or is this really a bug? The test program, of course, doesn't

Possible compiler bug in Visual C++ 2012 (x86)?

我与影子孤独终老i 提交于 2019-11-30 16:23:16
问题 I'm currently experiencing random floating point errors when compiling for x86 targets using VC++ 11 (CTP Update 1) . See the short example "test.cpp" below, and compile using: cl /GL /O2 /EHsc test.cpp /link /MACHINE:X86 The output should be 10 == 10 , but it produces 10 == 0 when /GL (whole program optimization) is enabled. The problem seems to be that get_scaling_factor() pushes the result on the floating point stack, but the calling function is expecting it in the SSE register XMM0 .

Why are generic and non-generic structs treated differently when building expression that lifts operator == to nullable?

只谈情不闲聊 提交于 2019-11-30 10:55:00
This looks like a bug in lifting to null of operands on generic structs. Consider the following dummy struct, that overrides operator== : struct MyStruct { private readonly int _value; public MyStruct(int val) { this._value = val; } public override bool Equals(object obj) { return false; } public override int GetHashCode() { return base.GetHashCode(); } public static bool operator ==(MyStruct a, MyStruct b) { return false; } public static bool operator !=(MyStruct a, MyStruct b) { return false; } } Now consider the following expressions: Expression<Func<MyStruct, MyStruct, bool>> exprA =

Why does this generics scenario cause a TypeLoadException?

ⅰ亾dé卋堺 提交于 2019-11-30 08:02:23
问题 This got a bit long-winded, so here's the quick version: Why does this cause a runtime TypeLoadException? (And should the compiler prevent me from doing it?) interface I { void Foo<T>(); } class C<T1> { public void Foo<T2>() where T2 : T1 { } } class D : C<System.Object>, I { } The exception occurs if you try to instantiate D. Longer, more exploratory version: Consider: interface I { void Foo<T>(); } class C<T1> { public void Foo<T2>() where T2 : T1 { } } class some_other_class { } class D :

VBA: What is causing this string argument passed to ParamArray to get changed to a number (that looks suspiciously like a pointer)?

拟墨画扇 提交于 2019-11-30 05:19:29
FINAL EDIT: It does indeed appear to be a compiler bug - see the accepted answer. Using VBA within Excel 2007, I have the following code in 'Class1': Option Explicit Public Function strange(dummy As String, ParamArray pa()) Debug.Print pa(LBound(pa)) End Function Public Sub not_strange(dummy As String, ParamArray pa()) Debug.Print pa(LBound(pa)) End Sub Public Function also_not_strange(ParamArray pa()) Debug.Print pa(LBound(pa)) End Function and some mode code in a module: Option Explicit Public Function not_strange_either(dummy As String, ParamArray pa()) Debug.Print pa(LBound(pa)) End

(Default) construct an object for every variadic type

笑着哭i 提交于 2019-11-30 04:37:34
问题 Consider this code snippet: void Foo(std::string str1, std::string str2) {} template<typename... Types> void Bar() { Foo(Types{}...); // wont compile } Bar<std::string, std::string>(); What I want to do here is to default construct two std::string objects inside the Bar method and pass them to Foo . However my vain attempts (one of them being in the snippet) wont compile so I am wondering whether this is even possible. I compiled with VC 2013, which throws compiler errors at me. As stated in

What's special about R and L in the C++ preprocessor?

别等时光非礼了梦想. 提交于 2019-11-30 04:11:28
I ran the following code through the Visual Studio 2013 preprocessor. The output surprises me. Contents of hello.cpp: #define A(j) #j A(A?) A(B?) A(C?) A(D?) A(E?) A(F?) A(G?) A(H?) A(I?) A(J?) A(K?) A(L?) A(M?) A(N?) A(O?) A(P?) A(Q?) A(R?) A(S?) A(T?) A(U?) A(V?) A(W?) A(X?) A(Y?) A(Z?) The command: cl /P hello.cpp hello.i contains: #line 1 "hello.cpp" "A?" "B?" "C?" "D?" "E?" "F?" "G?" "H?" "I?" "J?" "K?" "L" "M?" "N?" "O?" "P?" "Q?" "R" "S?" "T?" "U?" "V?" "W?" "X?" "Y?" "Z?" I ran into this while trying to call A(L?p:q), which resulted in "Lp:q" which is not good for me. Is this proper,