-
Notifications
You must be signed in to change notification settings - Fork 267
[BUG] Initialization vs assignment in a loop #1049
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
To Reproduce
main: () =
{
i := 0;
p: std::unique_ptr<int>;
while i < 3 next i++ {
std::cout << i << "\n";
p = new<int>(i);
std::cout << p* << "\n";
}
}The p = new<int> line generates a call to p.construct, which works for the first iteration to initialize p. Then on the second iteration, an assignment was intended, but p.construct is called again, which causes a contract violation.
0
0
1
Contract violation
terminate called without an active exception
Aborted (core dumped)
git cppfront, g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working