Visual Studio 2017 and constexpr

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Visual Studio 2017 and constexpr

Post by albinopapa » November 4th, 2017, 6:59 pm

Image

I have a little issue I want to share. I have made some constexpr classes and functions and in VS2015.3 there isn't a problem. I can mouse over my constexpr variables and intellisense shows me the correct results. However, in VS2017.4 I get some strange results.

I have included a test project, it gets the same results as the image, but is a console app instead of a Win32 app. All you have to do is open the project and put your mouse over the variables and wait for intellisense to show the values. When ran, the values are correct, so I guess I shouldn't be worried. Since it works in VS2015 I'm guessing it's something wrong with VS2017. If you have the same issue I'd like to get a response back so I can maybe file a bug report.

My VS2015 version is 14.0.25431.01
My VS2017 version is 15.4.2

NOTE:
My mouse pointer is over the size variable of: constexpr auto size = RectI(pt, ext).Dimensions();
Attachments
ConstexprTest.zip
(8.55 KiB) Downloaded 122 times
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Visual Studio 2017 and constexpr

Post by MrGodin » November 6th, 2017, 1:21 am

My VS 2017 is 15.1 and i shows the proper values but in this constexpr auto size = RectI( pt, ext ).Dimensions(); where RectI is underlined red with the tool tip saying
expression must have a constant value
access to uninitialized subobject (member "Point<T>::x [with T = int]").
with RectI(pt,ext) both pt and ext show proper initialization on mouse over so i dunno lol
Curiosity killed the cat, satisfaction brought him back

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Visual Studio 2017 and constexpr

Post by chili » November 6th, 2017, 1:34 am

Yeah, intellisense for constexpr has been fucked a little bit from the start in 2017. About 50% of messages I get from ppl having 'trouble' are messages about errors with constexpr which aren't actual errors, just intellisense false alarms.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Visual Studio 2017 and constexpr

Post by albinopapa » November 6th, 2017, 3:56 am

@MrGodin: That's funny you get that msg, without the .Dimensions() call I do get the red underline with the exact same message, but with the function call, it goes away. I was actually going to ask about that message next.

@chili: Have you updated VS2017 to update 4? If so, have you tried any constexpr if expressions?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Visual Studio 2017 and constexpr

Post by albinopapa » November 11th, 2017, 10:31 pm

With the messed up intellisense in vs2017 and vs2015 not having constexpr if, testing this shit is difficult. Even had an issue in vs2015 where intellisense got the result right, but didn't compile because in vs2015 it says you can't have more than one return statement.

I eventually just made a templated structure and specializations to return the Rect associated with type I wanted. I know constexpr if is suppose to help eliminate the need for all the template shenanigans, but without intellisense's help I can't use it. I really don't want to learn GCC or Clang unless they have a GUI build system, I hate using command-line.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply