http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59621

            Bug ID: 59621
           Summary: wrong caret / lineno for wrong ctor field initializer
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jan.kratochvil at redhat dot com
                CC: dodji at gcc dot gnu.org
            Target: x86_64-unknown-linux-gnu

class C {
public:
  void *ap,*bp;
  C(int i,void *p):ap(i)
  ,bp(p)
  {}
};

g++ -c cxxctor.C -Wall -g

FAIL: gcc (GCC) 4.8.3 20131023 (prerelease)
FAIL: gcc (GCC) 4.9.0 20131119 (experimental)
FAIL: gcc-c++-4.8.2-7.fc19.x86_64
cxxctor.C: In constructor ‘C::C(int, void*)’:
cxxctor.C:5:8: error: invalid conversion from ‘int’ to ‘void*’ [-fpermissive]
   ,bp(p)
        ^

PASS: clang-3.3-3.fc19.x86_64
cxxctor.C:4:20: error: cannot initialize a member subobject of type 'void *'
with an lvalue of type 'int'
  C(int i,void *p):ap(i)
                   ^  ~
1 error generated.

The error may be really confusing for many non-trivial ctor parameters.

Reply via email to