compiler-bug

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

旧城冷巷雨未停 提交于 2019-12-30 01:21: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

G++ and clang++ incompatibility with standard library when building shared libraries?

强颜欢笑 提交于 2019-12-25 06:37:06
问题 If I have a file clang.cpp containing: #include <map> void myfunc() { std::map<int, int> mymap; const int x = 20; myfoo[x] = 42; } and main.cpp containing: void myfunc(); int main() { myfunc(); } compiling clang++ -g clang.cpp -shared -fPIC -o libclang.so -stdlib=libstdc++ -std=c++11 and clang++ -g main.cpp -L -Wl.,-rpath=. -lclang -lstdc++ -o a.out -stdlib=libstc++ -std=c++11 will run fine. However, if I add gcc.cpp containing: #include <tuple> template std::pair<int const, int>::pair(std:

Fix for bizarre “%a” format behavior with g++ 4.9.1?

眉间皱痕 提交于 2019-12-23 07:48:20
问题 Compiler: 64-bit MinGW G++ 4.9.1 from the Nuwen distro, under Windows 8.1. Code: #ifdef INCLUDE_IOSTREAM # include <iostream> #endif #include <stdio.h> // ::snprintf #include <stdlib.h> // EXIT_SUCCESS, EXIT_FAILURE #include <stdexcept> // std::exception #ifdef snprintf # error snprintf defined as macro #endif #ifdef _MSC_VER auto const snprintf = _snprintf; #endif void test( double const value, int const precision) { char buffer[34]; snprintf( buffer, sizeof( buffer ), "%.*a", precision,

Fix for bizarre “%a” format behavior with g++ 4.9.1?

余生颓废 提交于 2019-12-23 07:48:01
问题 Compiler: 64-bit MinGW G++ 4.9.1 from the Nuwen distro, under Windows 8.1. Code: #ifdef INCLUDE_IOSTREAM # include <iostream> #endif #include <stdio.h> // ::snprintf #include <stdlib.h> // EXIT_SUCCESS, EXIT_FAILURE #include <stdexcept> // std::exception #ifdef snprintf # error snprintf defined as macro #endif #ifdef _MSC_VER auto const snprintf = _snprintf; #endif void test( double const value, int const precision) { char buffer[34]; snprintf( buffer, sizeof( buffer ), "%.*a", precision,

GCC bug? Chaining methods, broken sequence point

拜拜、爱过 提交于 2019-12-21 07:07:19
问题 I've been debugging a program for some time, and eventually found the error was due to a reference not being updated as I thought it would be. Here's a example that shows the problem I encountered: #include <iostream> using namespace std; struct Test { Test& set(int& i){ i = 10; return *this; } Test& print(const int& i){ cout << i << endl; return *this; } }; int main(void){ int i = 0; Test t; t.set(i).print(i + 5); return 0; } I had expected that the print() method here would output 15, but

Are function-local typedefs visible inside C++0x lambdas?

我只是一个虾纸丫 提交于 2019-12-19 05:17:27
问题 I've run into a strange problem. The following simplified code reproduces the problem in MSVC 2010: template <typename T> struct dummy { static T foo(void) { return T(); } }; int main(void) { typedef dummy<bool> dummy_type; auto x = []{ bool b = dummy_type::foo(); }; // auto x = []{ bool b = dummy<bool>::foo(); }; // works } The typedef I created locally in the function doesn't seem to be visible in the lambda. If I replace the typedef with the actual type, it works as expected. Here are some

Are explicit conversion operators allowed in braced initializer lists?

时光怂恿深爱的人放手 提交于 2019-12-19 05:14:08
问题 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:

Why does this Haskell code run slower with -O?

两盒软妹~` 提交于 2019-12-18 10:44:08
问题 This piece of Haskell code runs much slower with -O , but -O should be non-dangerous. Can anyone tell me what happened? If it matters, it is an attempt to solve this problem, and it uses binary search and persistent segment tree: import Control.Monad import Data.Array data Node = Leaf Int -- value | Branch Int Node Node -- sum, left child, right child type NodeArray = Array Int Node -- create an empty node with range [l, r) create :: Int -> Int -> Node create l r | l + 1 == r = Leaf 0 |

Possible compiler bug in MSVC12 (VS2013) with designated initializer

早过忘川 提交于 2019-12-18 05:44:13
问题 Using VS2013 Update 2, I've stumbled on some strange error message : // test.c int main(void) { struct foo { int i; float f; }; struct bar { unsigned u; struct foo foo; double d; }; struct foo some_foo = { .i = 1, .f = 2.0 }; struct bar some_bar = { .u = 3, // error C2440 : 'initializing' : cannot convert from 'foo' to 'int' .foo = some_foo, .d = 4.0 }; // Works fine some_bar.foo = some_foo; return 0; } Both GCC and Clang accept it. Am I missing something or does this piece of code exposes a

Possible compiler bug in MSVC12 (VS2013) with designated initializer

∥☆過路亽.° 提交于 2019-12-18 05:44:11
问题 Using VS2013 Update 2, I've stumbled on some strange error message : // test.c int main(void) { struct foo { int i; float f; }; struct bar { unsigned u; struct foo foo; double d; }; struct foo some_foo = { .i = 1, .f = 2.0 }; struct bar some_bar = { .u = 3, // error C2440 : 'initializing' : cannot convert from 'foo' to 'int' .foo = some_foo, .d = 4.0 }; // Works fine some_bar.foo = some_foo; return 0; } Both GCC and Clang accept it. Am I missing something or does this piece of code exposes a