[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: position.hh compile error C4146 (VisualStudio 2017)
From: |
Akim Demaille |
Subject: |
Re: position.hh compile error C4146 (VisualStudio 2017) |
Date: |
Sat, 18 Aug 2018 14:59:53 +0200 |
Hi!
> Le 18 août 2018 à 07:36, 長田偉伸 <address@hidden> a écrit :
>
> [Description]
>
> I used flex to generate the source code.
> After that, when I compiled using VisualStudio 2017, an error of
> C4146 occurred.
>
> I modified the file containing the error as follows.
>
> # (original) position.hh:111
> return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
>
> # (edited) position.hh:111
> return (0 < rhs || -1 * static_cast<unsigned int>(rhs) < lhs
>
> I compiled it again and confirmed that no error occurred
>
>
> [Environment]
> OS: Windows10
> Visual Studio 2017 (C++)
>
> Version: bison (GNU Bison) 3.0.5
>
>
> Thank you,
Amazing…
According to http://www.externsoft.ch/media/swf/cpp11-iso.html,
we have in the grammar of C++ (with focus on what matters here):
unary_expression:
• postfix_expression
• unary_operator cast_expression
cast_expression
• unary_expression
• '(' type_id ')' cast_expression
unary_operator:
• '+'
• '-'
postfix_expression:
• 'dynamic_cast' '<' type_id '>' '(' expression ')'
• ‘static_cast' '<' type_id '>' '(' expression ')'
So it is my reading that Visual Studio is wrong here.
I don’t like the -1 *, could you please rather check that parens would suffice?
return (0 < rhs || -(static_cast<unsigned int>(rhs)) < lhs
Thanks!
- position.hh compile error C4146 (VisualStudio 2017), 長田偉伸, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017),
Akim Demaille <=
- Message not available
- Message not available
- Re: position.hh compile error C4146 (VisualStudio 2017), 長田偉伸, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Rici Lake, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Akim Demaille, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Rici Lake, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Hans Åberg, 2018/08/19