Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • hyteg hyteg
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 33
    • Issues 33
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • hyteg
  • hyteghyteg
  • Issues
  • #56

Closed
Open
Created Jan 22, 2018 by Marcus Mohr@mohrDeveloper

PointND constructor usage with initialiser list

I have an issue with constructing points using an initialiser list. I'd like to use a short form for constructing points where I only pass the coordinates. It would be concise and intuitive to use an approach like this

Point2D( { 2.0, 3.0 } )

That construct compiles with g++, icpc and cygwin64 and these parts in pipeline #6872 greenlight. However, clang produces the warning

./../../src/tinyhhg_core/mesh/MeshGenRectangle.cpp:179:77: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                meshInfo.vertices_[idx] = MeshInfo::Vertex( idx, Point3D( { midx, midy, 0.0 } ), Inner );
                                                                            ^~~~~~~~~~~~~~~
                                                                            {              }

which results in a failure due to the -Werror. This issue was also encountered by @daniel, see commit cffe5cc9. My question is, whether me being new to the newer C++ versions, am making a conceptual error, or is this an issue with clang as seems to be indicated by https://stackoverflow.com/questions/31555584/why-is-clang-warning-suggest-braces-around-initialization-of-subobject-wmis?

I can produce similar warnings in g++, when I enforce the -Wmissing-braces option, but that option was deliberately excluded from -Wall for C++ with GCC. I tried to solve the problem by adding additional braces as suggested by clang, but that makes the code incompilable with g++ because it now is unsure which constructor it should invoke

candidate: hhg::PointND<T, N>::PointND(const hhg::PointND<T, N>&) [with T = double; long unsigned int N = 2]
   PointND(const PointND& b)

candidate: hhg::PointND<T, N>::PointND(std::array<_Tp, _Nm>) [with T = double; long unsigned int N = 2]
   PointND(std::array<T, N> list)

Any suggestions?

Cheers
Marcus

Assignee
Assign to
Time tracking