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

Submitter:  Vladimir Markelov <vvm>
Submitted:  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>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code