bearophile writes:
>> Is this another compiler bug?
>
> The situation is nice:
>
> struct Foo1 {}
> struct Foo2 { int x; }
> const struct Foo3 { int* p; }
> struct Foo4 { int* p; }
> void bar1(Foo1 f) {}
> void bar2(Foo2 f) {}
> void bar3(Foo3 f) {}
> void bar4(Foo4 f) {}
> void main() {
> co
On 23.01.2011 19:05, Mafi wrote:
Am 23.01.2011 11:00, schrieb Dmitry Olshansky:
On 23.01.2011 2:02, bearophile wrote:
Is this another compiler bug?
The situation is nice:
struct Foo1 {}
struct Foo2 { int x; }
const struct Foo3 { int* p; }
struct Foo4 { int* p; }
void bar1(Foo1 f) {}
void bar2
Am 23.01.2011 11:00, schrieb Dmitry Olshansky:
On 23.01.2011 2:02, bearophile wrote:
Is this another compiler bug?
The situation is nice:
struct Foo1 {}
struct Foo2 { int x; }
const struct Foo3 { int* p; }
struct Foo4 { int* p; }
void bar1(Foo1 f) {}
void bar2(Foo2 f) {}
void bar3(Foo3 f) {}
v
Dmitry Olshansky:
> The first two are actually OK, since you pass a copy of a value type
> FooX to barX.
> If signature was void bar(ref FooX) then it should have failed.
> But the third makes me wonder what the *** is going on.
I have added the third case to this bug report of mine:
http://d.pu
On 23.01.2011 2:02, bearophile wrote:
Is this another compiler bug?
The situation is nice:
struct Foo1 {}
struct Foo2 { int x; }
const struct Foo3 { int* p; }
struct Foo4 { int* p; }
void bar1(Foo1 f) {}
void bar2(Foo2 f) {}
void bar3(Foo3 f) {}
void bar4(Foo4 f) {}
void main() {
const f1
> Is this another compiler bug?
The situation is nice:
struct Foo1 {}
struct Foo2 { int x; }
const struct Foo3 { int* p; }
struct Foo4 { int* p; }
void bar1(Foo1 f) {}
void bar2(Foo2 f) {}
void bar3(Foo3 f) {}
void bar4(Foo4 f) {}
void main() {
const f1 = Foo1();
bar1(f1); // no error
== Quote from bearophile (bearophileh...@lycos.com)'s article
> Sean Eskapp:
> > Nevermind, I realized it's because constness is transitive in pointers. A
> > const
> > struct with a pointer member has a const pointer member, and those can't be
> > implicitly cast to non-const pointer members.
> U
Sean Eskapp:
> Nevermind, I realized it's because constness is transitive in pointers. A
> const
> struct with a pointer member has a const pointer member, and those can't be
> implicitly cast to non-const pointer members.
Uhm, the struct having a pointer is not important. In theory this too can
== Quote from Sean Eskapp (eatingstap...@gmail.com)'s article
> Why doesn't this code work?
> struct Bar
> {
> int* x;
> }
> void foo(Bar a) {}
> void main()
> {
> const a = Bar();
> foo(a);
> }
> But replacing int* with some other type works fine? Even if a write a postblit
> fun
Sean Eskapp:
> Why doesn't this code work?
This works, the Bar instance you give to foo is const.
void foo(const Bar a) {}
Bye,
bearophile
Why doesn't this code work?
struct Bar
{
int* x;
}
void foo(Bar a) {}
void main()
{
const a = Bar();
foo(a);
}
But replacing int* with some other type works fine? Even if a write a postblit
function for Bar, it still fails to compile.
11 matches
Mail list logo