public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gccbugs@andreas-borchert.de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49850] New: Implicit creation of a temporary object when a constant reference is passed as parameter and the actual and formal types are not identical Date: Tue, 26 Jul 2011 09:27:00 -0000 [thread overview] Message-ID: <bug-49850-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49850 Summary: Implicit creation of a temporary object when a constant reference is passed as parameter and the actual and formal types are not identical Product: gcc Version: 4.4.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: gccbugs@andreas-borchert.de The following has been tested with g++ (Debian 4.4.5-8) 4.4.5 for the amd64 architecture as shipped with stable Debian 6.0. I do not have it tested for newer releases as I do not have them conveniently available. Following code demonstrates the problem: ---- code start ---- #include <iostream> #include <sys/types.h> using namespace std; size_t si; void foo(const unsigned int& ui) { cout << "address of ui = " << (long long int) &ui << endl; } int main() { cout << "address of si = " << (long long int) &si << endl; foo(si); } ---- code end ---- The code generated for the invocation of foo() in main() shows the problem: movq si(%rip), %rax movl %eax, -20(%rbp) leaq -20(%rbp), %rax movq %rax, %rdi call _Z3fooRKj Instead of passing the address of the global si variable, a temporary object is created (at 20(%rbp)) whose address is passed. If you test this program, the output shows the effect: address of si = 6295456 address of ui = 140734739682956 The apparent problem is that "unsigned int" and "size_t" do not match, at least not on this platform (size and signedness are different). But then I would expect an error and not the implicit creation of a temporary object of the appropriate type.
next reply other threads:[~2011-07-26 9:27 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-07-26 9:27 gccbugs@andreas-borchert.de [this message] 2011-07-26 10:21 ` [Bug c++/49850] " daniel.kruegler at googlemail dot com 2011-07-26 12:29 ` paolo.carlini at oracle dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-49850-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).