public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96096] New: g++-10.1 silently ignores function violating const instead of refusing to compile
@ 2020-07-07 15:59 agadethrowaway at gmail dot com
  2020-07-07 16:10 ` [Bug c++/96096] " mpolacek at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: agadethrowaway at gmail dot com @ 2020-07-07 15:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96096

            Bug ID: 96096
           Summary: g++-10.1 silently ignores function violating const
                    instead of refusing to compile
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: agadethrowaway at gmail dot com
  Target Milestone: ---

Created attachment 48842
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48842&action=edit
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();
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/96096] g++-10.1 silently ignores function violating const instead of refusing to compile
  2020-07-07 15:59 [Bug c++/96096] New: g++-10.1 silently ignores function violating const instead of refusing to compile agadethrowaway at gmail dot com
@ 2020-07-07 16:10 ` mpolacek at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-07 16:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96096

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thanks for the report.  Dup.

*** This bug has been marked as a duplicate of bug 95789 ***

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-07 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 15:59 [Bug c++/96096] New: g++-10.1 silently ignores function violating const instead of refusing to compile agadethrowaway at gmail dot com
2020-07-07 16:10 ` [Bug c++/96096] " mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).