Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[BUG] Implicit move on non-last use #884

Closed

Description

Title: Implicit move on non-last use.

Minimal reproducer (https://cpp2.godbolt.org/z/z1nWesaaa):

main: () = {
  x := 0;

  if true { _ = x; }

  {
    { _ = x; }

    _ = x;
  }
}
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp

Expected result:

    {static_cast<void>(x); }

    static_cast<void>(std::move(x));

Actual result and error:

    {static_cast<void>(std::move(x)); }

    static_cast<void>(std::move(x));
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "/app/example.cpp2"


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "/app/example.cpp2"
auto main() -> int;

//=== Cpp2 function definitions =================================================

#line 1 "/app/example.cpp2"
auto main() -> int{
#line 2 "/app/example.cpp2"
  auto x {0}; 

  if (true) {static_cast<void>(x); }

  {
    {static_cast<void>(std::move(x)); }

    static_cast<void>(std::move(x));
  }
}
Output:
Program returned: 0

See also:

Activity

  1. ghost added
    bug
    on Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions