[Interest] error: taking address of temporary [-fpermissive]

justin at ics.com justin at ics.com
Fri Jun 1 21:00:46 CEST 2012


The compiler is worried about you possibly storing that pointer to a date which in that context is a temporary. You aren't but the correct way to fix this in C++ is to pass date as a const reference parameter. You get the speed of a pointer, but much safer code.


On 6/1/12 2:40 PM Robert Wood wrote:

Adding QMAKE_CXXFLAGS=-fpermissive in additional arguments in the 
projects tab does the trick.


I'd like to know why there is the change and how to fix it properly though.


An example of a rogue lines is this:


queryString += "\"" + sqlFormatString(&ui->dateInDateEdit->date()) + "\",";



The routine is defined as follows:


QString enter_invoice_in::sqlFormatString(QDate *date);


So, I'm passing a pointer to a date which is on a form.


Thanks again.




On 01/06/12 17:53, Konstantin Tokarev wrote:
>
>
> 01.06.2012, 20:11, "Robert Wood"<robert.wood at apostrophe.co.uk>:
>> Folks,
>>
>> I have just upgraded to Mageia Linux 2 and am now getting this compile
>> error:
>>
>> error: taking address of temporary [-fpermissive]
>>
>> This was previously compiling just fine.
>>
>> I'm now running Creator 2.4.1 Based on Qt 4.8.0.
>>
>> Anyone know what is going on please?
>
> BTW compiler proposes you to add -fpermissive to flags to get this code
> accepted as it was before.
>

_______________________________________________

Interest mailing list

robert.wood at apostrophe.co.uk
http://lists.qt-project.org/mailman/listinfo/interest



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120601/7f014f3f/attachment.html>


More information about the Interest mailing list