Created attachment 48842 [details] Minimal bug reproduction code Attached code compiled with: g++-10 (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0 with compile line: g++-10 Const_Violation_Silent_Error.cpp -o Const_Violation_Silent_Error compiles whereas g++-9 (g++-9 (Ubuntu 9.3.0-11ubuntu0~18.04.1) 9.3.0) correctly refuses to with error: error: binding reference of type ‘dummy&’ to ‘const dummy’ discards qualifiers... Not only does this code compile when it should not, but it will simply quietly never enter Modify_Object(). Copy of attached code: struct dummy{ int int_param; }; inline void Modify_Object(dummy &object){ object.int_param=0; } template <bool is_learning=true> void Templated_Function(){ const dummy R{0}; Modify_Object(R); } int main(){ Templated_Function(); }
Thanks for the report. Dup. *** This bug has been marked as a duplicate of bug 95789 ***