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 7853413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:40:59+00:00 2026-06-02T19:40:59+00:00

typedef decltype(true ? (long&&)0 : (long&&)0) T; What should T be? According to gcc

  • 0
typedef decltype(true ? (long&&)0 : (long&&)0) T;

What should T be?

According to gcc (4.7), it’s long. According to clang (trunk), it’s long&&. This difference is causing clang to fail to compile code that uses gcc 4.7’s libstdc++. Who is right?

UPDATE: As ildjarn points out, Clang is right, and as Richard Smith points out, the error libstdc++ is due to an error in the Standard. Here is the relevant GCC bug, and the relevant Defect Report.

  • 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-06-02T19:41:01+00:00Added an answer on June 2, 2026 at 7:41 pm

    Clang is right. N3337 §7.1.6.2/4:

    The type denoted by decltype(e) is defined as follows:

    • if e is an unparenthesized id-expression or an unparenthesized class member access, decltype(e) is the type of the entity named by e. If there is no such entity, or if e names a set of overloaded functions, the program is ill-formed;
    • otherwise, if e is an xvalue, decltype(e) is T&&, where T is the type of e;
    • otherwise, if e is an lvalue, decltype(e) is T&, where T is the type of e;
    • otherwise, decltype(e) is the type of e.

    The operand of the decltype specifier is an unevaluated operand.

    §5/6:

    [ Note: An expression is an xvalue if it is:

    • the result of calling a function, whether implicitly or explicitly, whose return type is an rvalue reference to object type,
    • a cast to an rvalue reference to object type,
    • a class member access expression designating a non-static data member of non-reference type in which the object expression is an xvalue, or
    • a .* pointer-to-member expression in which the first operand is an xvalue and the second operand is a pointer to data member.

    In general, the effect of this rule is that named rvalue references are treated as lvalues and unnamed rvalue references to objects are treated as xvalues; rvalue references to functions are treated as lvalues whether named or not. —end note ]

    I was wary earlier that a literal 0 may somehow prevent this from qualifying as an object type in this context, but §3.9/8 clarifies things:

    An object type is a (possibly cv-qualified) type that is not a function type, not a reference type, and not a void type.

    The conditional operator doesn’t affect anything here – §5.16/4:

    If the second and third operands are glvalues of the same value category and have the same type, the result is of that type and value category and it is a bit-field if the second or the third operand is a bit-field, or if both are bit-fields.

    In this case both are of the same value category (xvalue), and xvalues are glvalues.

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

Sidebar

Related Questions

I'm trying to do this: typedef std::map<std::string, time_t> my_map; const mymap& some_function(); class bla
typedef float v4sf __attribute__ ((mode(V4SF))); This is in GCC. Anyone knows the equivalence syntax?
Why does this fail to compile? (g++-4.5) template < typename U > static void
This typedef: typedef DWORD WINAPI (* CM_Open_DevNode_Key)(DWORD, DWORD, DWORD, DWORD, PHKEY, DWORD); compiles fine
typedef set<int, less<int> > SetInt; Please explain what this code does.
typedef boost::variant<long long,double,string> possibleTypes ; set<possibleTypes,less<possibleTypes> > ascSet ; set<possibleTypes,greater<possibleTypes> > descSet ; When
struct C { int Foo(int i) { return i; } typedef decltype(C::Foo) type; };
typedef char bool; doesn't work (Edit: it doesn't compile for fatal error C1004: unexpected
NOTE : This question was originally asked way back in 2012. Before the decltype
typedef long int INT; typedef unsigned char byte; #define MAX_CITIES (INT)2.7e6 #define MAX_LEN (int)1e6

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.