Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
June 01, 2005 error in recent dmc | ||||
---|---|---|---|---|
| ||||
I got this with a recent (843.6n) dmc, but it was ok in about 834/835 Is this a bug, or something wrong in the wxWidgets code (code based on oleutils.h) chris C:\compiler>dmc -mn -c -g -o+none -Ar -Ae -H -HO- dmc_test.cpp dmc_test.cpp(9) : Error: reference must refer to same type or be const Had: int and: int & { ^ dmc_test.cpp(18) : Error: '=', ';' or ',' expected } ^ dmc_test.cpp(20) : Error: identifier or '( declarator )' expected --- errorlevel 1 dmc_test.cpp: #define ULONG int class wxAutoULong { public: wxAutoULong(ULONG value = 0) : m_Value(value) { } operator ULONG&() { return m_Value; } ULONG& operator=(ULONG value) { return m_Value = value; } private: ULONG m_Value; }; wxAutoULong A, B ; int main { A=B; } |
June 01, 2005 Re: error in recent dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris elliott | "chris elliott" <biol75@york.ac.uk> wrote in message news:d7kk7t$1uld$1@digitaldaemon.com... > ULONG& operator=(ULONG value) { return m_Value = value; } This is the problem line, it tries to convert: return m_Value=value; into a reference. But it isn't a reference, it's an assignment expression. Rewrite as: m_Value = value; return m_Value; |
June 02, 2005 Re: error in recent dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | thank you for the clear explanation
chris
Walter wrote:
> "chris elliott" <biol75@york.ac.uk> wrote in message
> news:d7kk7t$1uld$1@digitaldaemon.com...
>
>> ULONG& operator=(ULONG value) { return m_Value = value; }
>
>
> This is the problem line, it tries to convert:
> return m_Value=value;
> into a reference. But it isn't a reference, it's an assignment expression.
> Rewrite as:
> m_Value = value;
> return m_Value;
>
>
|
June 02, 2005 Re: error in recent dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <newshound@digitalmars.com> wrote in message news:d7lfbj$2nmg$1@digitaldaemon.com... > > "chris elliott" <biol75@york.ac.uk> wrote in message news:d7kk7t$1uld$1@digitaldaemon.com... > > ULONG& operator=(ULONG value) { return m_Value = value; } > > This is the problem line, it tries to convert: > return m_Value=value; > into a reference. But it isn't a reference, it's an assignment expression. > Rewrite as: > m_Value = value; > return m_Value; I forgot to mention, the reason it "worked" before was the compiler rewrote the code as: tmp = (m_Value = value); return tmp; This is no longer in conformance with the C++ Standard, so was removed. |
June 03, 2005 Re: error in recent dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter |
Walter wrote:
> "Walter" <newshound@digitalmars.com> wrote in message
> news:d7lfbj$2nmg$1@digitaldaemon.com...
>
>>"chris elliott" <biol75@york.ac.uk> wrote in message
>>news:d7kk7t$1uld$1@digitaldaemon.com...
>>
>>> ULONG& operator=(ULONG value) { return m_Value = value; }
>>
>>This is the problem line, it tries to convert:
>> return m_Value=value;
>>into a reference. But it isn't a reference, it's an assignment expression.
>>Rewrite as:
>> m_Value = value;
>> return m_Value;
>
>
> I forgot to mention, the reason it "worked" before was the compiler rewrote
> the code as:
> tmp = (m_Value = value);
> return tmp;
> This is no longer in conformance with the C++ Standard, so was removed.
>
>
thanks, the code also "works" with VC, Borland, watcom compilers (and I guess gcc)
chris
|
June 03, 2005 Re: error in recent dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris elliott | chris elliott wrote: > > I forgot to say, how good it is to have dm spot such code bugs !Thanks again for all the rapid support >> > thanks, the code also "works" with VC, Borland, watcom compilers (and I guess gcc) > > chris |
Copyright © 1999-2021 by the D Language Foundation