Compiler Error C1061 due to too many nested if/else in MANTA_main.cpp #76276

Closed
opened 2020-04-30 20:25:32 +02:00 by Nikhil Shringarpurey · 23 comments

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.

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.
Author
Member

Added subscriber: @Nikhil.Net

Added subscriber: @Nikhil.Net
Member

Added subscriber: @EitanSomething

Added subscriber: @EitanSomething
Member

Can you post this on https://devtalk.blender.org.

Can you post this on https://devtalk.blender.org.
Author
Member

Roger - doing it now!

Roger - doing it now!
Author
Member
Posted here: https://devtalk.blender.org/t/new-windows-compiler-error-introduced-by-mantaflow-change/12929
Member

Added subscribers: @sebbas, @ankitm

Added subscribers: @sebbas, @ankitm
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

It has been brought to @sebbas' attention.

It has been brought to @sebbas' attention.

This issue was referenced by 713ad9d971

This issue was referenced by 713ad9d9715a570627e762b16fda110476e3ba2b

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sebastián Barschkis self-assigned this 2020-04-30 20:55:21 +02:00
Author
Member

This comment was removed by @Nikhil.Net

*This comment was removed by @Nikhil.Net*
Author
Member

@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.

@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.

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo

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

@Nikhil.Net Yes, if you have a patch that would certainly be helpful. @LazyDodo Or did you already come up with a refactor?
Author
Member

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.

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.

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 ](https://developer.blender.org)). I can review it and commit on your behalf.
Member

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

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
Author
Member

@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.

@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.

Added subscriber: @ErickNyanduKabongo

Added subscriber: @ErickNyanduKabongo

Hello guys,

@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 :)

Hello guys, @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 :)

@ErickNyanduKabongo That's a different issue :)

@ErickNyanduKabongo That's a different issue :)
Member

also already fixed.

also already fixed.

Thanks :)

Thanks :)
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
7 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#76276
No description provided.