http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49850

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 
2011-07-26 10:20:47 UTC ---
(In reply to comment #0)

> #include <sys/types.h>

To make the definition of size_t available, you should better include a
standard header, like <stddef.h>

> 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.

You might expect this, but this would be in contradiction to what the C++
standard requires ([dcl.init.ref] p5 last bullet). GCC is required to accept
this conversion. If you want to prevent this, use a pointer type or a non-const
reference instead of a reference to const as function parameter.

This does not look like a compiler defect to me.

Reply via email to