reinterpret_cast from rvalue to rvalue referenceWhat are the differences between a pointer variable and a...

Rests in pickup measure (anacrusis)

Were pen cap holes designed to prevent death by suffocation if swallowed?

Employer asking for online access to bank account - Is this a scam?

Logarithm of dependent variable is uniformly distributed. How to calculate a confidence interval for the mean?

Why is this Simple Puzzle impossible to solve?

How can people dance around bonfires on Lag Lo'Omer - it's darchei emori?

Ticket sales for Queen at the Live Aid

What is the most important source of natural gas? coal, oil or other?

How can I find where certain bash function is defined?

Is there a down side to setting the sampling time of a SAR ADC as long as possible?

Why do Russians call their women expensive ("дорогая")?

Which noble houses were destroyed during the Game of Thrones?

Apparent Ring of Craters on the Moon

When did God say "let all the angels of God worship him" as stated in Hebrews 1:6?

Identifying an object pointer by generating and using a unique ID

Full backup on database creation

What is the difference between nullifying your vote and not going to vote at all?

How to convert to standalone document a matrix table

Can a wire having a 610-670 THz (frequency of blue light) AC frequency supply, generate blue light?

Why are C64 games inconsistent with which joystick port they use?

Does this degree 12 genus 1 curve have only one point over infinitely many finite fields?

How long does it take to crack RSA 1024 with a PC?

What is the object moving across the ceiling in this stock footage?

Canon 70D often overexposing or underexposing shots



reinterpret_cast from rvalue to rvalue reference


What are the differences between a pointer variable and a reference variable in C++?When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?What are rvalues, lvalues, xvalues, glvalues, and prvalues?Why is this program erroneously rejected by three C++ compilers?GCC accepts `constexpr struct {} s;` but Clang rejects it. Who is correct?Lambda returning itself: is this legal?`extern` declarations and following defintions of class template instances with and without parameter listsWhy do (only) some compilers use the same address for identical string literals?Declaring defaulted assignment operator as constexpr: which compiler is right?Using incomplete type in a member function of a class template






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







7















Just a simple does it compile test.
gcc accepts the following while clang and msvc reject it: https://godbolt.org/z/DlUasL



float test()
{
return reinterpret_cast<float&&>(0x7F800000);
}


Which one is right according to the standard?










share|improve this question


















  • 2





    Pretty sure that's going to be UB in any case as there is no float to alias here.

    – Quentin
    9 hours ago













  • Yeah it's derived from the more "usual" reinterpret_cast<float&>(variable) pattern.

    – Trass3r
    9 hours ago


















7















Just a simple does it compile test.
gcc accepts the following while clang and msvc reject it: https://godbolt.org/z/DlUasL



float test()
{
return reinterpret_cast<float&&>(0x7F800000);
}


Which one is right according to the standard?










share|improve this question


















  • 2





    Pretty sure that's going to be UB in any case as there is no float to alias here.

    – Quentin
    9 hours ago













  • Yeah it's derived from the more "usual" reinterpret_cast<float&>(variable) pattern.

    – Trass3r
    9 hours ago














7












7








7








Just a simple does it compile test.
gcc accepts the following while clang and msvc reject it: https://godbolt.org/z/DlUasL



float test()
{
return reinterpret_cast<float&&>(0x7F800000);
}


Which one is right according to the standard?










share|improve this question














Just a simple does it compile test.
gcc accepts the following while clang and msvc reject it: https://godbolt.org/z/DlUasL



float test()
{
return reinterpret_cast<float&&>(0x7F800000);
}


Which one is right according to the standard?







c++ standards-compliance






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 9 hours ago









Trass3rTrass3r

3,1171732




3,1171732








  • 2





    Pretty sure that's going to be UB in any case as there is no float to alias here.

    – Quentin
    9 hours ago













  • Yeah it's derived from the more "usual" reinterpret_cast<float&>(variable) pattern.

    – Trass3r
    9 hours ago














  • 2





    Pretty sure that's going to be UB in any case as there is no float to alias here.

    – Quentin
    9 hours ago













  • Yeah it's derived from the more "usual" reinterpret_cast<float&>(variable) pattern.

    – Trass3r
    9 hours ago








2




2





Pretty sure that's going to be UB in any case as there is no float to alias here.

– Quentin
9 hours ago







Pretty sure that's going to be UB in any case as there is no float to alias here.

– Quentin
9 hours ago















Yeah it's derived from the more "usual" reinterpret_cast<float&>(variable) pattern.

– Trass3r
9 hours ago





Yeah it's derived from the more "usual" reinterpret_cast<float&>(variable) pattern.

– Trass3r
9 hours ago












1 Answer
1






active

oldest

votes


















7














The conversion this reinterpret_cast expression seeks to perform is not among the list of conversions [expr.reinterpret.cast] that a reinterpret_cast can perform [expr.reinterpret.cast]/1. 0x7F800000 is a literal of integral type. The only conversion reinterpret_cast could perform that converts from a value of integral type to some other type is that of turning such a value into a pointer type [expr.reinterpret.cast]/5. float&& is a reference type, not a pointer type. The only conversion reinterpret_cast can perform that converts to a reference type is that of converting a glvalue expression [expr.reinterpret.cast]/11. 0x7F800000 is not a glvalue. Thus, this code is ill-formed. The fact that GCC would accept this is quite surprising to me and, I would say, definitely a bug that should be reported…






share|improve this answer


























  • I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

    – Trass3r
    9 hours ago












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56316648%2freinterpret-cast-from-rvalue-to-rvalue-reference%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









7














The conversion this reinterpret_cast expression seeks to perform is not among the list of conversions [expr.reinterpret.cast] that a reinterpret_cast can perform [expr.reinterpret.cast]/1. 0x7F800000 is a literal of integral type. The only conversion reinterpret_cast could perform that converts from a value of integral type to some other type is that of turning such a value into a pointer type [expr.reinterpret.cast]/5. float&& is a reference type, not a pointer type. The only conversion reinterpret_cast can perform that converts to a reference type is that of converting a glvalue expression [expr.reinterpret.cast]/11. 0x7F800000 is not a glvalue. Thus, this code is ill-formed. The fact that GCC would accept this is quite surprising to me and, I would say, definitely a bug that should be reported…






share|improve this answer


























  • I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

    – Trass3r
    9 hours ago
















7














The conversion this reinterpret_cast expression seeks to perform is not among the list of conversions [expr.reinterpret.cast] that a reinterpret_cast can perform [expr.reinterpret.cast]/1. 0x7F800000 is a literal of integral type. The only conversion reinterpret_cast could perform that converts from a value of integral type to some other type is that of turning such a value into a pointer type [expr.reinterpret.cast]/5. float&& is a reference type, not a pointer type. The only conversion reinterpret_cast can perform that converts to a reference type is that of converting a glvalue expression [expr.reinterpret.cast]/11. 0x7F800000 is not a glvalue. Thus, this code is ill-formed. The fact that GCC would accept this is quite surprising to me and, I would say, definitely a bug that should be reported…






share|improve this answer


























  • I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

    – Trass3r
    9 hours ago














7












7








7







The conversion this reinterpret_cast expression seeks to perform is not among the list of conversions [expr.reinterpret.cast] that a reinterpret_cast can perform [expr.reinterpret.cast]/1. 0x7F800000 is a literal of integral type. The only conversion reinterpret_cast could perform that converts from a value of integral type to some other type is that of turning such a value into a pointer type [expr.reinterpret.cast]/5. float&& is a reference type, not a pointer type. The only conversion reinterpret_cast can perform that converts to a reference type is that of converting a glvalue expression [expr.reinterpret.cast]/11. 0x7F800000 is not a glvalue. Thus, this code is ill-formed. The fact that GCC would accept this is quite surprising to me and, I would say, definitely a bug that should be reported…






share|improve this answer















The conversion this reinterpret_cast expression seeks to perform is not among the list of conversions [expr.reinterpret.cast] that a reinterpret_cast can perform [expr.reinterpret.cast]/1. 0x7F800000 is a literal of integral type. The only conversion reinterpret_cast could perform that converts from a value of integral type to some other type is that of turning such a value into a pointer type [expr.reinterpret.cast]/5. float&& is a reference type, not a pointer type. The only conversion reinterpret_cast can perform that converts to a reference type is that of converting a glvalue expression [expr.reinterpret.cast]/11. 0x7F800000 is not a glvalue. Thus, this code is ill-formed. The fact that GCC would accept this is quite surprising to me and, I would say, definitely a bug that should be reported…







share|improve this answer














share|improve this answer



share|improve this answer








edited 9 hours ago

























answered 9 hours ago









Michael KenzelMichael Kenzel

10.6k11926




10.6k11926













  • I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

    – Trass3r
    9 hours ago



















  • I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

    – Trass3r
    9 hours ago

















I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

– Trass3r
9 hours ago





I thought so, thanks. gcc.gnu.org/bugzilla/show_bug.cgi?id=86633

– Trass3r
9 hours ago




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56316648%2freinterpret-cast-from-rvalue-to-rvalue-reference%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...