﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
11	Compiler uses all Resources when Copying from Generic Function Result	ajbeach		"If I try to compile the following code the cfa compiler uses 100% CPU and 100% MEM and crashes the computer.
{{{
maybe(char) letter = maybe_value('a');
}}}
However the following code compiles with no noticeable slowdown:
{{{
maybe(char) letter;
letter = maybe_value('a');
maybe(char) rune = letter;
}}}

----

I also tried annotating the argument, (char)'a', and that got it to work. I'm not sure why as under the current rules that should be a no-op. But it does suggest a resolver issue.

----

I also tried annotating the call of maybe_value with maybe(char) and got the following error:
{{{
*CFA assertion error* from program ""cfa-cpp"" in ""virtual void CodeGen::CodeGenerator::visit(TypeExpr*)"" at line 733 in file ""CodeGen/CodeGenerator.cc"": TypeExpr should not reach code generation.
Stack back trace for: /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp
(0) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::CodeGenerator::visit(TypeExpr*)+0xd2 [0x4630d2]
(1) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::GenType::handleGeneric[abi:cxx11](ReferenceToType*)+0x206 [0x468d56]
(2) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::GenType::visit(StructInstType*)+0x32 [0x46b6f2]
(3) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::genType(Type*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool)+0x1fc [0x4691ac]
(4) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::CodeGenerator::visit(ObjectDecl*)+0xa7 [0x467247]
(5) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::CodeGenerator::visit(DeclStmt*)+0x18 [0x4636d8]
(6) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::CodeGenerator::visit(CompoundStmt*)+0x16c [0x46665c]
(7) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::CodeGenerator::visit(FunctionDecl*)+0xef [0x4670af]
(8) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : CodeGen::generate(std::__cxx11::list<Declaration*, std::allocator<Declaration*> >, std::ostream&, bool, bool, bool, bool)+0x80 [0x462be0]
(9) /home/ajbeach/cfa-cc/lib/cfa/cfa-cpp : main(/*unknown*/)+0x89f [0x45c37f]
CFA Translator error: cfa-cpp failed with signal 6
}}}

----

Some related maybe function definitions (from the new containers/maybe library header)
{{{
forall(otype T)
void ?{}(maybe(T) * this, maybe(T) other);

forall(otype T)
maybe(T) ?=?(maybe(T) * this, maybe(T) other);

forall(otype T)
maybe(T) maybe_value(T value);
}}}"	defect	new	minor	cfa-cc	1.0			
