bugGNU Astronomy Utilities - Bugs: bug #48609, Modifier 'const' should be used...


You are not allowed to post comments on this tracker with your current authentication level.

bug #48609: Modifier 'const' should be used for function arguments and results where appropriate

Submitted by:  Vladimir Markelov <vvm>
Submitted on:  Sun 24 Jul 2016 01:56:52 AM UTC  
Category:  All Gnuastro Severity:  3 - Normal
Item Group:  Source code Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Sun 24 Jul 2016 01:56:52 AM UTC, original submission:  

A lot of functions takes pointers to data and returns pointers. It would be good to mark 'const' pointers if a function does not change the data or a caller should not change the returned data.


1. It will be a good hint for a user - a person can easily see if a function changes his/her data or function just reads them

2. A compiler can be a real helper and warn a user if the user tries to change the data(returned by a function) that should be changed at all

A good example for #2 is function 'hdutypestring'. It returns 'char*' but really it returns a pointer to read-only data, so a client code will likely to crash if, e.g, the client code tries to change the returned value in place. A compiler warns the user in this case about casting a 'const char*' to 'char *'.

Vladimir Markelov <vvm>
Project Member


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by vvm (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    No changes have been made to this item

    Back to the top

    Powered by Savane 3.7