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

  • SEARCH
  • Home
  • 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 6241901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:51:05+00:00 2026-05-24T11:51:05+00:00

Clang’s own diagnostics propaganda contains this exerpt: Since Clang has range highlighting, it never

  • 0

Clang’s own diagnostics propaganda contains this exerpt:

Since Clang has range highlighting, it never needs to pretty print your code back out to you. This is particularly bad in G++ (which often emits errors containing lowered vtable references), but even GCC can produce inscrutible error messages in some cases when it tries to do this.

Googling this phrase doesn’t give anything very helpful, and the subsequent example is completely unrelated.

Can someone please post an example of what it’s talking about?

Thanks.

  • 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-24T11:51:06+00:00Added an answer on May 24, 2026 at 11:51 am

    Here is an example:

    struct a {
      virtual int bar();
    };
    
    struct foo : public virtual a {
    };
    
    void test(foo *P) {
      return P->bar()+*P;
    }
    

    Clang produces:

    t.cc:9:18: error: invalid operands to binary expression ('int' and 'foo')
      return P->bar()+*P;
             ~~~~~~~~^~~
    

    GCC 4.2 produces:

    t.cc: In function ‘void test(foo*)’:
    t.cc:9: error: no match for ‘operator+’ in ‘(((a*)P) + (*(long int*)(P->foo::<anonymous>.a::_vptr$a + -0x00000000000000020)))->a::bar() + * P’
    t.cc:9: error: return-statement with a value, in function returning 'void'
    

    GCC does this because its C++ frontend is bolted on top of the C frontend in many cases. Instead of building C++-specific Abstract Syntax Trees (ASTs) for various C++ operations, the parser just lowers them immediately to their C equivalent. In this case, GCC synthesizes an struct to contain the vtable, and the pointer dereference to bar is then lowered into a series of C pointer dereferences, casts, pointer arithmetic etc.

    Clang does not have this problem, because it has a very clean AST that directly represents the source code. If you change the example to:

    struct a {
      virtual int bar();
    };
    
    struct foo : public virtual a {
    };
    
    void test(foo *P) {
      P->bar();
    }
    

    .. so that the code is valid, then ask clang to dump its ast with “clang -cc1 -ast-dump t.cc”, you get:

    ...
    void test(foo *P)
    (CompoundStmt 0x10683cae8 <t.cc:8:19, line:10:1>
      (CXXMemberCallExpr 0x10683ca78 <line:9:3, col:10> 'int'
        (MemberExpr 0x10683ca40 <col:3, col:6> '<bound member function type>' ->bar 0x10683bef0
          (ImplicitCastExpr 0x10683cac8 <col:3> 'struct a *' <UncheckedDerivedToBase (virtual a)>
            (ImplicitCastExpr 0x10683ca28 <col:3> 'struct foo *' <LValueToRValue>
              (DeclRefExpr 0x10683ca00 <col:3> 'struct foo *' lvalue ParmVar 0x10683c8a0 'P' 'struct foo *'))))))
    

    -Chris

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

Sidebar

Related Questions

Clang has new feature called ARC. Concept looks cool. Is this feature support detecting
Clang has a very cool extension named block bringing true lambda function mechanism to
This is related to Clang 3.1 and C++11 support status , but I could
For GCC and Clang, I can easily do this: // absolute value inline constexpr
Has anybody run Clang as a C compiler on ppc architecture? I am trying
I want to install Clang compliler on my system. I went to this link
Came across a proposal called rvalue reference for *this in clang's C++11 status page
I'd like to use clang on my Xcode iPhone project. However this is the
I found this: Changing Compiler to llvm-clang on existing iPhone Project But that does
This code works with clang but g++ says: error: ‘A::A()’ is protected class A

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.