Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:33:31+00:00 2026-05-28T04:33:31+00:00

I have the following constructor of an object Segment::Segment(QPointF const& start, QPointF const& end):

  • 0

I have the following constructor of an object

Segment::Segment(QPointF const& start, QPointF const& end):
  mOrigin(toVector3df(start)),mEnd(toVector3df(end)){    
}

mOrigin is of type Vector3df and the function toVector3df(QPointF const&) returns a temporary Vector3df. So far so good. The code compiles fine and works like a charm under linux, gcc 4.4.3. most warnings activated.

Now I wanted to cross-compile the same code for a Nokia Smartphone (Meamo Fremantle)
and all of a sudden I get very weird compiler warnings:

include/vector3d.h: In constructor 'Segment::Segment(const QPointF&, const QPointF&)':
include/vector3d.h:64: warning: 'this.902' is used uninitialized in this function
include/vector3d.h:64: note: 'this.902' was declared here

First: Of course there is no real variable called this.902 inside ‘Vecto3df’ so my first question would be: “Has anyone seen some warning like this ?” Further there is nothing wrong with Vector3df constructors, they are very simple and toVector3df(QPointF const&) is a one liner non-member template function that works perfect in other parts of the code.
Vector3df inherits from a template that only defines non-member functions, no variables no, virtual functions.

Second, when I change the above code to the following

Segment::Segment(QPointF const& start, QPointF const& end):
  mOrigin(),mEnd(){
  mOrigin = toVector3df(start);
  mEnd = toVector3df(end);
}

The code works fine without any warnings.
So what am I missing here ? Has anybody an idea what the origin of the warnings could be. Am I violating some doctrine I’m unaware of. Is the fremantle compiler (Maemo 5, Qt 4.6.2) more severe or buggy ?

Thanks in advance, Martin

Edit:
Here is a minimal example, sorry for the length 😛

#include <iostream>
#include <sstream>
#include <QPoint>

template<typename T> class IoEnabled {};

template<typename T>
class Vector3d: public IoEnabled<Vector3d<T> > {
  private:
    T mX; T mY; T mZ;
  public:
    Vector3d(T const& x, T const& y, T const& z=0.0) : mX(x), mY(y), mZ(z) {}
};
typedef Vector3d<float> Vector3df;

template<class T>
Vector3df toVector3df(T const& p){
  return Vector3df(p.x(),p.y(),0.0);
}

class Segment {
  private:
    Vector3df mOrigin; Vector3df mEnd;
  public:
    Segment(QPointF const& start, QPointF const& end):
        mOrigin(toVector3df(start)),mEnd(toVector3df(end)){
        //if toVector3df(...) is moved from the initializer to the body it works
    }
};

int main(int argc, char **argv) {
  (void) argc; (void) argv;
  Segment temp(QPointF(1,2),QPointF(3,4));
  return 0;
}

Compiler call:

 g++ -c -pipe -Werror -Wall -Wextra -Wunused -Wundef -Wpointer-arith -Wcast-align -Wwrite-strings -Wredundant-decls -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -D_REENTRANT -Wall -W -DQT_GL_NO_SCISSOR_TEST -DQT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH=1024 -DMAEMO -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/opt/QtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/share/qt4/mkspecs/linux-g++-maemo5 -I. -I/opt/QtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/include/QtCore -I/opt/QtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/include/QtGui -I/opt/QtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/include -Isrc -Irelease/moc -o release/obj/main.o src/main.cpp

The Template inheritance seems to be crucial, if the Vector3d does not inherit everything works fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:33:32+00:00Added an answer on May 28, 2026 at 4:33 am

    There is nothing wrong in using functions returning a temporary in member initializer lists.
    Even the order in which the members will be inialized is well defined in the standard.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following object: //the constructor function function NewsScroller() { } //now put
I have a class with the following constructor: public UniqueField(Collection<Object> items) { this.items=items; }
I have an associative array (object) of the following construction var menu = new
I have following situation. In a constructor of a pseudo class I attach a
I have a class which has the following constructor public DelayCompositeDesigner(DelayComposite CompositeObject) { InitializeComponent();
I have the following code: Some functions: A::A(int i_a) {cout<<int Ctor\n;} //conversion constructor void
I have in my Form constructor, after the InitializeComponent the following code: using (WebClient
I have the following constructor method which opens a MemoryStream from a file path:
I have the following two constructors in my base class: protected ExternalSystemException( params Object[]
I have some IronPython code that is creating a Mutex using the following constructor:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.