compiler-bug

(Known) compiler bug in VC12?

旧巷老猫 提交于 2019-11-27 21:54:24
This program, when compiled with VC12 (in Visual Studio 2013 RTM) [1] leads to a crash (in all build configurations), when really it shouldn't: #include <string> void foo(std::string const& oops = {}) { } int main() { foo(); } I know of two silent bad codegen bugs that might be related: https://connect.microsoft.com/VisualStudio/feedback/details/800364/initializer-list-calls-object-destructor-twice http://connect.microsoft.com/VisualStudio/feedback/details/800104/ Honestly I think these are different, though. Does anyone know whether there is an actively tracked bug on connect for this whether

(this == null) in C#!

可紊 提交于 2019-11-27 09:08:05
问题 Due to a bug that was fixed in C# 4, the following program prints true . (Try it in LINQPad) void Main() { new Derived(); } class Base { public Base(Func<string> valueMaker) { Console.WriteLine(valueMaker()); } } class Derived : Base { string CheckNull() { return "Am I null? " + (this == null); } public Derived() : base(() => CheckNull()) { } } In VS2008 in Release mode, it throws an InvalidProgramException. (In Debug mode, it works fine) In VS2010 Beta 2, it doesn't compile (I didn't try

operator new inside namespace

三世轮回 提交于 2019-11-27 06:52:55
问题 namespace X { void* operator new (size_t); } gives error message as: error: ‘void* X::operator new(size_t)’ may not be declared within a namespace Is it a gcc compiler bug ? In older gcc version it seems to be working. Any idea, why it's not allowed ? Use case : I wanted to allow only custom operator new/delete for the classes and wanted to disallow global new/operator . Instead of linker error, it was easy to catch compiler error; so I coded: namespace X { void* operator new (size_t); }

'Delegate 'System.Action' does not take 0 arguments.' Is this a C# compiler bug (lambdas + two projects)?

好久不见. 提交于 2019-11-27 04:10:43
Consider the code below. Looks like perfectly valid C# code right? //Project B using System; public delegate void ActionSurrogate(Action addEvent); //public delegate void ActionSurrogate2(); // Using ActionSurrogate2 instead of System.Action results in the same error // Using a dummy parameter (Action<double, int>) results in the same error // Project A public static class Class1 { public static void ThisWontCompile() { ActionSurrogate b = (a) => { a(); // Error given here }; } } I get a compiler error 'Delegate 'Action' does not take 0 arguments.' at the indicated position using the

Maybe a C# compiler bug in Visual Studio 2015

久未见 提交于 2019-11-27 01:41:01
I think this is a compiler bug. The following console application compiles und executes flawlessly when compiled with VS 2015: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var x = MyStruct.Empty; } public struct MyStruct { public static readonly MyStruct Empty = new MyStruct(); } } } But now it's getting weird: This code compiles, but it throws a TypeLoadException when executed. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var x = MyStruct.Empty; } public struct MyStruct { public static readonly MyStruct? Empty = null; }

(Known) compiler bug in VC12?

こ雲淡風輕ζ 提交于 2019-11-26 20:49:40
问题 This program, when compiled with VC12 (in Visual Studio 2013 RTM) [1] leads to a crash (in all build configurations), when really it shouldn't: #include <string> void foo(std::string const& oops = {}) { } int main() { foo(); } I know of two silent bad codegen bugs that might be related: https://connect.microsoft.com/VisualStudio/feedback/details/800364/initializer-list-calls-object-destructor-twice http://connect.microsoft.com/VisualStudio/feedback/details/800104/ Honestly I think these are

Why doesn't volatile in java 5+ ensure visibility from another thread?

不羁的心 提交于 2019-11-26 17:55:31
问题 According to: http://www.ibm.com/developerworks/library/j-jtp03304/ Under the new memory model, when thread A writes to a volatile variable V, and thread B reads from V, any variable values that were visible to A at the time that V was written are guaranteed now to be visible to B And many places on the internet state that the following code should never print "error": public class Test { volatile static private int a; static private int b; public static void main(String [] args) throws

What is the behavior of printing NULL with printf&#39;s %s specifier?

橙三吉。 提交于 2019-11-26 13:22:39
Came across an interesting interview question: test 1: printf("test %s\n", NULL); printf("test %s\n", NULL); prints: test (null) test (null) test 2: printf("%s\n", NULL); printf("%s\n", NULL); prints Segmentation fault (core dumped) Though this might run fine on some systems, atleast mine is throwing a segmentation fault. What would be the best explanation of this behavior? Above code is in C. Following is my gcc info: deep@deep:~$ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 First things first: printf is expecting a valid (i.e. non-NULL) pointer for its %s argument so passing it a

Maybe a C# compiler bug in Visual Studio 2015

感情迁移 提交于 2019-11-26 12:28:09
问题 I think this is a compiler bug. The following console application compiles und executes flawlessly when compiled with VS 2015: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var x = MyStruct.Empty; } public struct MyStruct { public static readonly MyStruct Empty = new MyStruct(); } } } But now it\'s getting weird: This code compiles, but it throws a TypeLoadException when executed. namespace ConsoleApplication1 { class Program { static void Main(string[]

What is the behavior of printing NULL with printf&#39;s %s specifier?

你。 提交于 2019-11-26 03:40:41
问题 Came across an interesting interview question: test 1: printf(\"test %s\\n\", NULL); printf(\"test %s\\n\", NULL); prints: test (null) test (null) test 2: printf(\"%s\\n\", NULL); printf(\"%s\\n\", NULL); prints Segmentation fault (core dumped) Though this might run fine on some systems, atleast mine is throwing a segmentation fault. What would be the best explanation of this behavior? Above code is in C. Following is my gcc info: deep@deep:~$ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5)