bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pointer to non-const std::string in position and location should be a po


From: Yuriy Solodkyy
Subject: Pointer to non-const std::string in position and location should be a pointer to const std::string
Date: Thu, 25 Jun 2020 15:22:48 -0700

Hi,

I’m using bison 3.6.3 on MacOS via brew. I see that in the C++ generated parser 
location and position take pointer to std::string with filename via a pointer 
to modifiable std::string. I don’t see the filename itself being modified 
anywhere in the parser, so I was wondering why not accept a pointer to const 
std::string instead? Without this, I need to either copy filename first 
somewhere or const_cast when I can ensure the lifetime. The thing is that when 
I invoke my own function passing it a filename in const string&, which in turn 
calls parse (in pull mode) I can ensure that the filename will be valid during 
the entire duration of the call to parse yet I cannot use a pointer to it to 
initialize location because location demands the pointer to non-const string, 
which in my opinion is unnecessary. Can you please change your source for 
position and location take pointer to const std::string instead?

Thank you!
Yuriy


reply via email to

[Prev in Thread] Current Thread [Next in Thread]