Page MenuHome

Compiler Error C1061 due to too many nested if/else in MANTA_main.cpp
Closed, ResolvedPublic

Description

This bug was introduced by commit 21485e94. As a result, Blender can no longer be compiled on Windows after that commit.

When compiling in Windows (using Visual Studio 2017 or 2019), error C1061 results:

M:\BlenderSource\blender\intern\mantaflow\intern\MANTA_main.cpp(1003,11): fatal error C1061: compiler limit: blocks nested too deeply

This is due to the commit above adding more if/else clauses than 128 which exceeds the hard compiler limit for MSBuild. Also, this is a really inelegant block of string tests, and probably could use a cleanup/refactor anyway.

Event Timeline

Ankit Meel (ankitm) changed the task status from Needs Triage to Confirmed.Apr 30 2020, 8:37 PM

It has been brought to @Sebastián Barschkis (sebbas)' attention.

Robert Guetzkow (rjg) triaged this task as High priority.Apr 30 2020, 8:40 PM

@Sebastián Barschkis (sebbas) I finished the code changes that would convert the long chain of if statements into a switch, which I think would be faster to execute. Since you had to remove the else statements, that means each if is getting evaluated per call to the function. Let me know if you'd like me to submit a pull request for you to review, or if there's a better way you want me to send for your review.

Also, feel free to tell me to take a hike if this is not worth doing - this is my first potential code submission and I am more than happy to fade to the background and submit at a later time.

@Nikhil Shringarpurey (Nikhil.Net) Yes, if you have a patch that would certainly be helpful.
@Ray molenkamp (LazyDodo) Or did you already come up with a refactor?

So, I do have a tested/working patch that would allow potentially unlimited values going forward with no need of nested if/else, but I regret to say I am a bit of a noob at submitting it. I'm reading thru the developer docs on it right now to get the process down.

Ok, great. Instead of using arcanist (the tool to submit patches on phabricator) you can also upload the git diff output (can be done through "Submit Code" on the frontpage). I can review it and commit on your behalf.

i did have a refactor but i trashed it after i saw you already had a committed a fix

it pretty much turned

if (varName == "USING_DISSOLVE")
  ss << (mmd->domain->flags & FLUID_DOMAIN_USE_DISSOLVE ? "True" : "False");
else if (varName == "SOLVER_DIM")
  ss << mmd->domain->solver_res;
etcetc

into

if (varName == "USING_DISSOLVE")
 return (mmd->domain->flags & FLUID_DOMAIN_USE_DISSOLVE ? "True" : "False");
if (varName == "SOLVER_DIM")
  return std::to_string(mmd->domain->solver_res);
etcetc

i theoretically could see small perf increase since it's not doing all kinds of bogus string compares if the result is already known, but depending a bit on how often this is called, unsure if it will be a measurable

@Sebastián Barschkis (sebbas) I have created the following diff and set you as a reviewer (I think I did that right): https://developer.blender.org/D7581

Thanks for feedback, and looking forward to your thoughts.

Hello guys,

@Ray molenkamp (LazyDodo) Is this the same problem that i m having or should i start another thread in Devtalk?
Here is the full log in Pasteall > https://pasteall.org/im58

Thanks in advance for your help :)