compiler-bug

“redundant cast to java.lang.Object” warning for necessary cast

雨燕双飞 提交于 2020-12-28 06:47:48
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf

Why does this code using __LINE__ compile under MSVC in Release mode, but not in Debug mode?

独自空忆成欢 提交于 2020-07-20 06:47:27
问题 Consider this program: #include <iostream> template<bool Debug = false, int Line = __LINE__> constexpr int adds(const int& a, const int& b) { if (Debug) std::cout << __FUNCTION__ << " called on line " << Line << '\n'; return (a + b); } int main() { std::cout << adds(3, 7) << '\n'; std::cout << adds<true, __LINE__> (5, 9) << '\n'; return 0; } When I try to compile and build this in Debug mode Visual Studio 2017 is generating these compiler errors: 1>------ Build started: Project: Simulator,

How to portably compare std::system_error exceptions to std::errc values?

↘锁芯ラ 提交于 2020-01-24 08:41:52
问题 As far as I've understood, one of the best practices to check system_error conditions in a portable manner is to compare their code() value with values in the std::errc enumeration. However, when I try to run the following code, this does not seem to work. #include <cassert> #include <cerrno> #include <system_error> int main() { try { throw std::system_error(ENOENT, std::system_category()); } catch (std::system_error const & e) { assert(e.code() == std::errc::no_such_file_or_directory); // <-

Happily linking incompatible types leads to chaos

南楼画角 提交于 2020-01-13 11:43:32
问题 I've been trying to figure out some boundaries of g++ , especially linking (C++) object files. I found the following curiosity which I tried to compress as much as possible before asking. Code File common.h #ifndef _COMMON_H #define _COMMON_H #include <iostream> #define TMPL_Y(name,T) \ struct Y { \ T y; \ void f() { \ std::cout << name << "::f " << y << std::endl; \ } \ virtual void vf() { \ std::cout << name << "::vf " << y << std::endl; \ } \ Y() { \ std::cout << name << " ctor" << std:

Happily linking incompatible types leads to chaos

旧时模样 提交于 2020-01-13 11:43:25
问题 I've been trying to figure out some boundaries of g++ , especially linking (C++) object files. I found the following curiosity which I tried to compress as much as possible before asking. Code File common.h #ifndef _COMMON_H #define _COMMON_H #include <iostream> #define TMPL_Y(name,T) \ struct Y { \ T y; \ void f() { \ std::cout << name << "::f " << y << std::endl; \ } \ virtual void vf() { \ std::cout << name << "::vf " << y << std::endl; \ } \ Y() { \ std::cout << name << " ctor" << std:

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

空扰寡人 提交于 2020-01-09 02:13:08
问题 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

c++ array zero-initialization: Is this a bug, or is this correct?

倖福魔咒の 提交于 2020-01-01 04:27:08
问题 Note: We are speaking about (supposedly) C++98 compliant compilers, here. This is not a C++11 question. We have a strange behavior in one of our compilers and we're not sure if this is Ok or if this is a compiler bug: // This struct has a default constructor struct AAA { AAA() : value(0) {} int value ; } ; // This struct has a member of type AAA and an array of int, both surrounded // by ints struct BBB { int m_a ; AAA m_b ; int m_c ; int m_d[42] ; } ; When BBB is initialized as such: BBB bbb