IncludeHelp_logo

  • Data Structure
  • Coding Problems
  • C Interview Programs
  • C++ Aptitude
  • Java Aptitude
  • C# Aptitude
  • PHP Aptitude
  • Linux Aptitude
  • DBMS Aptitude
  • Networking Aptitude
  • AI Aptitude
  • MIS Executive
  • Web Technologie MCQs
  • CS Subjects MCQs
  • Databases MCQs
  • Programming MCQs
  • Testing Software MCQs
  • Digital Mktg Subjects MCQs
  • Cloud Computing S/W MCQs
  • Engineering Subjects MCQs
  • Commerce MCQs
  • More MCQs...
  • Machine Learning/AI
  • Operating System
  • Computer Network
  • Software Engineering
  • Discrete Mathematics
  • Digital Electronics
  • Data Mining
  • Embedded Systems
  • Cryptography
  • CS Fundamental
  • More Tutorials...
  • Tech Articles
  • Code Examples
  • Programmer's Calculator
  • XML Sitemap Generator
  • Tools & Generators

IncludeHelp

Advertisement

Home » C programs » C common errors programs

Error: Assignment of read-only variable in C | Common C program Errors

Here, we will learn how and when error 'assignment of read-only variable in C' occurs and how to fix it? By IncludeHelp Last updated : March 10, 2024

Error: Assignment of read-only variable in C

Error "assignment of read-only variable in C" occurs, when we try to assign a value to the read-only variable i.e. constant.

In this program, a is a read-only variable or we can say a is an integer constant, there are two mistakes that we have made:

  • While declaring a constant, value must be assigned – which is not assigned.
  • We cannot assign any value after the declaration statement to a constant – which we are trying to assign.

Consider the program:

How to fix it?

Assign value to the variable while declaring the constant and do not reassign the variable.

Correct Code

C Common Errors Programs »

Related Programs

  • Error: undefined reference to 'main' in C
  • Error: Expected ';' before 'return' in C
  • Error: expected ')' before ';' token in C
  • Error: missing terminating double quote character in C
  • Error: 'Hello'/Text undeclared while printing Hello world using printf()
  • Error: expected declaration specifies before printf in C
  • Error: expected declaration or statement at end of input in C
  • Fatal Error: stio.h: No such file or directory in C
  • Error: Invalid escape sequence in C
  • Error: Unterminated comment (Invalid comment block) in C
  • Error: Assign string to the char variable in C
  • Error: 'else' without a previous 'if' in C
  • Error: case label does not reduce to an integer constant in C
  • Error: duplicate case value in C
  • Error: Executing more than one case block in C
  • Error: switch quantity not an integer in C
  • Error: case label not within a switch statement in C
  • Error: Expected '}' before 'else' in C
  • Error: expected '=', ',', ',' 'asm' or ' _attribute_' before '
  • Error: Id returned 1 exit status (undefined reference to 'main')
  • Error: Assignment of read-only location in C

Comments and Discussions!

Load comments ↻

  • Marketing MCQs
  • Blockchain MCQs
  • Artificial Intelligence MCQs
  • Data Analytics & Visualization MCQs
  • Python MCQs
  • C++ Programs
  • Python Programs
  • Java Programs
  • D.S. Programs
  • Golang Programs
  • C# Programs
  • JavaScript Examples
  • jQuery Examples
  • CSS Examples
  • C++ Tutorial
  • Python Tutorial
  • ML/AI Tutorial
  • MIS Tutorial
  • Software Engineering Tutorial
  • Scala Tutorial
  • Privacy policy
  • Certificates
  • Content Writers of the Month

Copyright © 2024 www.includehelp.com. All rights reserved.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

NVIDIA driver error: assignment of read-only member ‘vm_flags’

I installed NVIDIA driver based on this suggesiton using the following command:

The above command installed nvidia-driver-535 (535.154.05-0ubuntu0.22.04.1) and other tools. Next, I tried installing CUDA but the installer throws the following error:

I looked at the crash file and found the following errors:

The crash and log files are uploaded to Pastebin.

Below is the enviroment information:

I found that this issue has been reported at here , here , and here . but they reported it with kernel 6.3, however I am using 6.2.

What is the workaround?

ravi's user avatar

  • I found a workaround by installing CUDA 12.3 on kernel 6.5.0-18-generic. Thank you very much –  ravi Commented Feb 17 at 7:40
  • if your are kind can you post it here ? –  Cornea Valentin Commented Feb 20 at 1:47
  • @CorneaValentin: What do want me to post? I can post it in easy to understand manner based on your comment –  ravi Commented Feb 20 at 3:04
  • nvm , i was made a fresh install of ubuntu now it's work , maybe was am issue due older kernels i had ... or video driver .. now i got working on 12.3 cuda with 545 driver –  Cornea Valentin Commented Feb 21 at 15:14
  • @CorneaValentin: Good to hear about it. What I found that for 12.3 CUDA you need kernel 6.5.0-18-generic and NVIDIA 545 driver. I posted detailed info here –  ravi Commented Feb 22 at 4:48

You must log in to answer this question.

Browse other questions tagged drivers nvidia kernel graphics cuda ..

  • The Overflow Blog
  • The evolution of full stack engineers
  • One of the best ways to get value for AI coding tools: generating tests
  • Featured on Meta
  • Bringing clarity to status tag usage on meta sites
  • Join Stack Overflow’s CEO and me for the first Stack IRL Community Event in...

Hot Network Questions

  • How to fold or expand the wingtips on Boeing 777?
  • Practice test paper answers all seem incorrect, but provider insists they are ... what am i missing?
  • Analog story - US provides food machines to other nations, with hidden feature
  • Guesstimate a multiple choice exam
  • What is vi command package?
  • Text processing: Filter & re-publish HTML table
  • ESTA for dual national: what can happen if I lie about being American?
  • The pronoun in short yes/no answers to rhetorical tag-questions with the generic "you"
  • Canonical decomposition as wedge sum up to homotopy equivalence
  • What does it mean for a predicate to be ground?
  • How much technological progress could a group of modern people make in a century?
  • Wrong explanation for why "electron can't exist in the nucleus"?
  • Can someone confirm this observed bug for `bc`? `scale=0` has no effect!
  • The meaning of "sharp" in "sharp sweetness"
  • Part bound and part living thing
  • Understanding the parabolic state of a quantum particle in the infinite square well
  • Is the product of two NONZERO elements independently drawn from a prime field uniformly distributed?
  • Movie / episode where a spaceplane is stuck in orbit
  • Disable encryption on wireguard
  • Consistency-proof of ZFC
  • What are the steps to write a book?
  • Has anyone returned from space in a different vehicle from the one they went up in? And if so who was the first?
  • How long should a wooden construct burn (and continue to take damage) until it burns out (and stops doing damage)
  • Mistake on car insurance policy about use of car (commuting/social)

error assignment of read only member c

C Board

  • Today's Posts
  • C and C++ FAQ
  • Mark Forums Read
  • View Forum Leaders
  • What's New?
  • Get Started with C or C++
  • C++ Tutorial
  • Get the C++ Book
  • All Tutorials
  • Advanced Search

Home

  • General Programming Boards
  • C Programming

Error: assignment of i_value in read-only object

  • Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems

Thread: Error: assignment of i_value in read-only object

Thread tools.

  • Show Printable Version
  • Email this Page…
  • Subscribe to this Thread…

Search Thread

  •   Advanced Search
  • Linear Mode
  • Switch to Hybrid Mode
  • Switch to Threaded Mode
  • View Profile
  • View Forum Posts

VeeDub is offline

Hello, I have two programs that to the best of my knowledge use the same data structures and contain the same statements. One program works and the other fails with the error in the title. No doubt there is a reason, but at this stage it is not clear to me. Please refer to the two attachments: Example_Data_Structure Linked_List_Example Example_Data_Structure is a short program that builds and executes as I would expect. Example_Data_Structure contains an extract of code from Linked_List_Example. For some reason the code works fine in isolation, but not when combined with the other statements. It's a mystery to me. Linked_List_Example, contains a lot more code (sorry), but also contains the same code as in Example_Data_Structure. I've had to include the whole program because obviously there is something in it which causes the following statement to fail. Code: record->i_value = 100; For reason; Code: 162|error: assignment of member ‘i_value’ in read-only object| For some reason I can't upload the other program. No errors but it doesn't appear in the Attachment Manager. Also the Attachment Manager states that uploaded programs are supposedly deleted after 1 hour; but my upload from yesterday is still there?

Attached Files

I don't have access to Attachments in 'My Settings' ?

Salem is offline

Example_Data_Structure.c seems fine to me. Code: $ gcc -Wall Example_Data_Structure.c $ ./a.out Record - detail: some string Record - value: 100
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. If at first you don't succeed, try writing your phone number on the exam paper .
Originally Posted by Salem It seems fine to me. Yes it is, the issue is that the same code in the other example doesn't work. I'm assuming that the issue must be due to some of the other statements I have in the 2nd program; it is not at all clear to me why the error is occurring. So I need to upload the other example so that I can get an informed opinion. The attachment manager seems buggy to me. It always seems to take multiple attempts to get an attachment to upload / appear; and I've not managed to upload the 2nd program at all??
Finally managed to upload the 2nd attachment
Well the big problem is you're missing a brace at the end of the else in add_record() Then Code: foo.c: In function ‘add_key’: foo.c:54:22: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] current->key = key; ^ foo.c:73:28: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] current->next->key = key; ^ Use strcpy to copy things. Code: foo.c: In function ‘add_record’: foo.c:89:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (current->record_list = NULL) { ^ foo.c:121:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (current->record_list = NULL) { ^ You probably meant to use == There's no reason to cast the return result of malloc. > record_list = (record_t *) malloc(sizeof(record_t)); Casting malloc - Cprogramming.com
Originally Posted by Salem There's no reason to cast the return result of malloc. > record_list = (record_t *) malloc(sizeof(record_t)); Casting malloc - Cprogramming.com Appreciate your reply, I must admit I have been programming on my laptop and with the smaller screen I was having trouble seeing the whole function. I should have used the "-" minus key to condense the code blocks to make sure that I had all the brackets matched up. I'm afraid I don't understand your last comment regarding casting malloc. Unfortunately I'm none the wiser, even after reading the included link. My understanding is that each time I add a new "record" in the list. I need to allocate memory for that record. And the statement Code: record_list= (record_t*) ... is the statement required to allocate the memory for the next record/structure in the list, before then populating the fields in the record. Can you show the statement that I should be using instead?
I mean you should be able to do this without upsetting the compiler. Code: record_list = malloc(sizeof(record_t)); The cast would cover up the mistake of not including stdlib.h If you get a message along the lines of 'cannot convert void* to type*', then that means you're using C++ to compile your C program. This is something you shouldn't be doing either.
Originally Posted by Salem The cast would cover up the mistake of not including stdlib.h If you get a message along the lines of 'cannot convert void* to type*', then that means you're using C++ to compile your C program. This is something you shouldn't be doing either. The includes that are specified are: Code: #include <stdio.h> #include <stdlib.h> #include <string.h> The compile options that I'm using are: Code: -------------- Build: Debug in Linked_List_example_with_Data_Structure_II (compiler: GNU GCC Compiler)--------------- gcc -Wall -g -c /home/dev/c/learn/Linked_List_example_with_Data_Structure_II/main.c -o obj/Debug/main.o gcc -o bin/Debug/Linked_List_example_with_Data_Structure_II obj/Debug/main.o Output file is bin/Debug/Linked_List_example_with_Data_Structure_II with size 10.74 KB Process terminated with status 0 (0 minute(s), 0 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
There is still an error in the add_record function. Using the debugger I observe that the execution crashes at line 96 Code: strcpy(current->record_list->c_detail1,record->c_detail1); Unfortunately this statement looks correct to me. I've used printf at line 92 & 93 to confirm that the record details (i.e. the "inputs" are correctly set. Perhaps the issue is with line 95, Code: record_list = (record_t *) malloc(sizeof(record_t)); although I don't observe any errors when this line is executed PS: I had issues uploading the attachment again. Does anybody else have issues with this. I'm using latest version of Chrome on Windows

Hodor is offline

Originally Posted by VeeDub Code: strcpy(current->record_list->c_detail1,record->c_detail1); current->record_list is NULL on line 96, as proven by line 89, and then you're trying to dereference (i.e. you're effectively trying to do NULL->c_detail1) so it crashes. On line 95, where is record_list even declared? Same for line 109... does this compile? Edit: nvm, I see now that it's a global that is somewhat hidden because it's indented badly. Why is it global?
Originally Posted by Hodor current->record_list is NULL on line 96, as proven by line 89, and then you're trying to dereference (i.e. you're effectively trying to do NULL->c_detail1) so it crashes. On line 95, where is record_list even declared? Same for line 109... does this compile? Edit: nvm, I see now that it's a global that is somewhat hidden because it's indented badly. Why is it global? Hello Hodor, My understanding is that line 95 Code: record_list = (record_t *) malloc(sizeof(record_t)); Allocates memory for a new record, which I then update in lines 96, 97 and 98. If I comment line 96 Code: strcpy(current->record_list->c_detail1,record->c_detail1); Then line 97 fails Code: current->record_list->i_value = record->i_value; So the issue must be in line 95 Code: record_list = (record_t *) malloc(sizeof(record_t)); But a similar statement works earlier in the code (line 161) to create a record structure Code: record = (record_t *) malloc(sizeof(record_t)); and I successfully update this record in main(); so I don't understand why line 95 isn't working. As to why the record structure is a global variable. My intention is to access and update the record structure in a number of functions - not just add_record.
When your code reaches line 96, what is the value of current->record_list? As far as I can see it's NULL, because program execution only reaches line 96 if current->record_list is NULL ( see line 89; i.e. it's still NULL when line 96 is reached ). You can't do Code: strcpy( current->record_list ->c_detail1 ,record->c_detail1); Because the part in bold must be NULL otherwise the line would never have been reached because execution only reaches line 96 if the part in bold is NULL (because of line 89). Maybe before reaching line 96, and after line 89, you have to do something like Code: current->record_list = record_list; (But don't quote me on that I haven't looked very closely at your code because I'm on a device that makes it difficult for me. That said you have to either add something like the line above or change lines 96-98 to use record_list rather than current->record_list or something else that is not NULL) Edit: What I'm suggesting is either : Code: /* Check head of record list */ if (current->record_list == NULL) { /* First record */ // printf("Record - detail: %s\n",record->c_detail1); // printf("Record - value: %d\n",record->i_value); record_list = (record_t *) malloc(sizeof(record_t)); current->record_list = record_list; strcpy(current->record_list->c_detail1,record->c_detail1); current->record_list->i_value = record->i_value; current->record_list->next = NULL; } /* current->record_list == NULL */ or Code: /* Check head of record list */ if (current->record_list == NULL) { /* First record */ // printf("Record - detail: %s\n",record->c_detail1); // printf("Record - value: %d\n",record->i_value); record_list = (record_t *) malloc(sizeof(record_t)); strcpy(record_list->c_detail1,record->c_detail1); record_list->i_value = record->i_value; record_list->next = NULL; }
Last edited by Hodor; 07-18-2020 at 10:14 PM .
Thanks Hodor, You're right of course Line 95 should have been Code: current->record_list = (record_t *) malloc(sizeof(record_t)); If I keep making enough mistakes I'll eventually start to learn. I just need to get to the point where I can fix them by myself. Cheers
Originally Posted by VeeDub Thanks Hodor, You're right of course Line 95 should have been Code: current->record_list = (record_t *) malloc(sizeof(record_t)); If I keep making enough mistakes I'll eventually start to learn. I just need to get to the point where I can fix them by myself. Cheers I made an edit while you were replying. Your way in this new post is fine as well, of course

Next

  • Jump to page:
  • Private Messages
  • Subscriptions
  • Who's Online
  • Search Forums
  • Forums Home
  • C++ Programming
  • C# Programming
  • Game Programming
  • Networking/Device Communication
  • Programming Book and Product Reviews
  • Windows Programming
  • Linux Programming
  • General AI Programming
  • Article Discussions
  • General Discussions
  • A Brief History of Cprogramming.com
  • Contests Board
  • Projects and Job Recruitment

subscribe to a feed

  • How to create a shared library on Linux with GCC - December 30, 2011
  • Enum classes and nullptr in C++11 - November 27, 2011
  • Learn about The Hash Table - November 20, 2011
  • Rvalue References and Move Semantics in C++11 - November 13, 2011
  • C and C++ for Java Programmers - November 5, 2011
  • A Gentle Introduction to C++ IO Streams - October 10, 2011

Similar Threads

How to read 2 adjacents strings object, int assignment to object incompatibility issue - java, what's wrong with my read function read from a txt file to an array of object, operator overloading - rhs object is modified by assignment operation, assignment of read-only location (vectors), tags for this thread.

View Tag Cloud

  • C and C++ Programming at Cprogramming.com
  • Web Hosting
  • Privacy Statement
  • Windows Programming
  • UNIX/Linux Programming
  • General C++ Programming
  • Readonly class variables in C++

  Readonly class variables in C++

error assignment of read only member c

A { : x; f() { x = 100; } } main() { A a; a.x = 50; 0; }
A { x; : setX( x) { ->x = x; } getX() { ->x; } };
A { _x; : A() : x(_x) { } setX( x) { ->_x = x; } &x; }; main() { A a; a.setX(50); cout << a.x << endl; a.x = 12; 0; }
A { : _x; : __property x = {read=_x}; }

The real problem is: We can not assign one object of this class to another object because of existence of reference variable.
And the solution is: Writing a copy-constructor
A{ : data{ member; }; : A(): set( data), get(set){} A( A &b): set( data(*b.set) ), get(set){} ~A(){ set; } A& =( A &b){ *set = *b.set; * ; } data * set; data * get; }; A a; a.set->member = 42; std::cout << a.get->member;
A { data_; : & get() { data_; } set( & data ) { data_ = data; } }; A a; a.set( 42 ); std::cout << a.get();
wrote:
why would I want to have to implement an assignment operator in order to have that proposed solution? It doesn't make things any easier does it?
std; < T> ReadOnly { : T & real_data; : ReadOnly( T & real_data_):real_data(real_data_){} ReadOnly & =( ReadOnly &) { cout << << endl; * ; } T &() { real_data;} }; MyClass { : real_x; : ReadOnly< > x; MyClass():real_x(0),x(real_x) {} MyClass( MyClass & obj):real_x(0),x(real_x) {real_x=obj.real_x;} SetX( n) {real_x=n;} }; print_int( n) {cout << n << endl;} print_double( d) {cout << d << endl;} set( & n, m) {n=m;} main() { MyClass a; a.SetX(1); MyClass b(a); b.SetX(2); cout << << endl; MyClass c; c=b; c.SetX(c.x+1); cout << ; cout << a.x << endl; cout << ; print_int(b.x); cout << ; print_double(c.x); 0; }
< T> FriendMaker { T Type;}; < T, C> ReadOnly { FriendMaker<C>::Type; : T data; ReadOnly & =( T & t) {data=t;} : T &() { data;} }; MyClass { : ReadOnly< ,MyClass> x; SetX( n) {x=n;} };
wrote:
Anyway I don't see the lack of the readonly keyword as a weakness.

C++ – Error in assignment of member in read-only object

c compiler-errors variable-assignment

I am working on worm_sim simulater , ubuntu, gcc, codeblocks IDE

traffic_source.h file

traffic_source.cpp

the value packet_generating_rate is not const but when i try to modify it either directly or using the set function it give me errors

although it is used on other files with no problem, any suggestion plz

Best Answer

As other's have already pointed out, the problem is that inside a const function (last const in the line) you cannot modify the members of the object. Effectively the member function is translated into something similar to: bool Traffic_source__can_send( const Traffic_source* this, void ) , there the this argument is a pointer to const . Which in turn means that packet_generating_rate is const in the context of the function.

There are three alternatives that you can follow here:

  • don't modify the member
  • don't mark the function const
  • make packet_generating_rate mutable

The first two options are the common ones: either the function is const and does not modify the object, or it is not const and can modify the object. There are cases however, where you want to modify a member within a const member pointer. In that case you can mark the member declaration as mutable to enable modification inside const member functions.

Note however that in general this is done when the member variable does not take part on the visible state of the object. For example a mutex variable does not change the value returned from a getter or the state of the object afterwards, but getters need to lock (modify) the object to obtain a consistent view of the object in multithreaded environments. The second typical example is a cache , where an object may offer an operation that is expensive to calculate, so the function performing that operation might cache the result for later. Again, whether the value is recalculated or retrieved from the cache it will be the same, so the visible state of the object does not change. Finally, sometimes you might need to abuse the construct to conform to an existing interface.

Now it is up to you to determine which of the three options to apply to your design. If you need to modify the member attribute, then either the member is part of the visible state and the function should not be const , or else it is not part of the state of the object and can be marked mutable .

Related Solutions

C++ – why can templates only be implemented in the header file.

Caveat: It is not necessary to put the implementation in the header file, see the alternative solution at the end of this answer.

Anyway, the reason your code is failing is that, when instantiating a template, the compiler creates a new class with the given template argument. For example:

When reading this line, the compiler will create a new class (let's call it FooInt ), which is equivalent to the following:

Consequently, the compiler needs to have access to the implementation of the methods, to instantiate them with the template argument (in this case int ). If these implementations were not in the header, they wouldn't be accessible, and therefore the compiler wouldn't be able to instantiate the template.

A common solution to this is to write the template declaration in a header file, then implement the class in an implementation file (for example .tpp), and include this implementation file at the end of the header.

This way, implementation is still separated from declaration, but is accessible to the compiler.

Alternative solution

Another solution is to keep the implementation separated, and explicitly instantiate all the template instances you'll need:

If my explanation isn't clear enough, you can have a look at the C++ Super-FAQ on this subject .

Bash – Command not found error in Bash variable assignment

You cannot have spaces around the = sign.

When you write:

bash tries to run a command named STR with 2 arguments (the strings = and foo )

bash tries to run a command named STR with 1 argument (the string =foo )

bash tries to run the command foo with STR set to the empty string in its environment.

I'm not sure if this helps to clarify or if it is mere obfuscation, but note that:

  • the first command is exactly equivalent to: STR "=" "foo" ,
  • the second is the same as STR "=foo" ,
  • and the last is equivalent to STR="" foo .

The relevant section of the sh language spec, section 2.9.1 states:

A "simple command" is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control operator.

In that context, a word is the command that bash is going to run. Any string containing = (in any position other than at the beginning of the string) which is not a redirection and in which the portion of the string before the = is a valid variable name is a variable assignment, while any string that is not a redirection or a variable assignment is a command. In STR = "foo" , STR is not a variable assignment.

Related Topic

  • Java – Why don’t Java’s +=, -=, *=, /= compound assignment operators require casting
  • C++ – use a pointer rather than the object itself

Error: assignment of Member '' in read-only Object

Asked 7 years, 8 months ago

Viewed 544 times

Why I have these mistakes I don’t understand. I know it has to do with ecoponto[pos].""="" but I don’t see why.

asked 2017/01/02 at 14:58

by pp fernandes • 97 points

You declared the parameter as const then you cannot modify it. If the intention is to modify you should not use this modifier. You may have other code problems, but these specific errors are generated by this.

Since you created a guy with typedef , could have used it in the parameter declaration. So it works, but it’s a waste. Could have declared ecoponto ecoponto[] . Or better yet, reverse the names on typedef , ideally the type names should be capitalized to avoid confusion with variable name, then the type would be Ecoponto .

answered 2017/01/02 at 15:04

by Maniero • 444,682 points

Alias - is not creating "Ecoponto" as a type in typedef, and then using "Ecoponto" as a variable name?

@jsbueno too. Edited. Thank you for remembering.

Browser other questions tagged c parameters

Driver 470.182.03 fails to compile with Linux 6.3.1

Same here . do you want to discuss a fix

I sort of figure that sooner or later the good NVidia folks will test their drivers on latest “stable” Linux. Only a matter of time. I have seen this before and it looks like there are some new memory management code in 6.3.1 with variables and structures that have changed. For the moment I can revert back to a 6.2.x kernel and things seem to work. That includes CUDA nvcc and NPP libs etc.

I found a fix, I documented it for Debian, including a patch, you could adapt it easily too:

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1036173

Hey guess what! The patch for the legacy 470.x series driver seems to work great with Linux 6.3.8. See full video on YouTube at NVidia drivers on Linux is a flail or fail? - YouTube with loads of fan noises and servers running around me. Sort of a rant but the driver wworks and so does CUDA. See patch at Tentative fix for NVIDIA 470.161.03 driver for Linux 6.3-rc1 · GitHub there.

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] assignment of read-only member -- occurs with cython tuple optimizations #5558

@hmaarrfk

hmaarrfk commented Jul 23, 2023

I was helping pyav update to cython 3

and I hit the following

Apply the patch:

index 9ad5391..b966582 100644 --- a/av/video/format.pyx +++ b/av/video/format.pyx @@ -47,14 +47,10 @@ cdef class VideoFormat(object): self.ptr = lib.av_pix_fmt_desc_get(pix_fmt) self.width = width self.height = height - # hmaarrfk -- 2023/07/23 - # Note on tuple([]) - # Cython 3 seems to have trouble with cdef tuples, so we use a list - # it complains about some const identifier not being able to get assigned - self.components = tuple([ + self.components = tuple( VideoFormatComponent(self, i) for i in range(self.ptr.nb_components) - ]) + ) def __repr__(self): if self.width or self.height:

Log and format.c.txt from 3.0.0 but I confirmed that it also occurs in main branch

that it compiles. I worked around it by using a list comprehension before the call.

Linux

3.9.16

main or 3.0.0 (conda-forge)

@da-woods

Successfully merging a pull request may close this issue.

@hmaarrfk

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Try to replace old boost with new one in old code and get error, "type": is not a member of boost::mpl::eval_if

I tried to compile old code (~15 years old - luabind) that uses very old boost version (sth like 1.30) with new version of boost 1.86.

I replaced some apply_if usages with eval_if like it is suggested in release notes of boost 1.32. However I stuck on some compilation error. I tried to prepare some minimum example of that problematic code below.

Compilation error:

I'm pretty sure that the reason is related to extract_parameter::iterator type definition. When I replaced it with simply unspecified structure it compiles well. I belive that the reason is that it cannot find iterator::type type. However it is well defined and I don't understand why it results with error.

  • metaprogramming
  • template-meta-programming

BartekPL's user avatar

It looks like the wrapping identity<> around iterator is missing.

Makes it compile for me (fixing the includes).

Live On Coliru

sehe's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged c++ boost metaprogramming template-meta-programming luabind or ask your own question .

  • The Overflow Blog
  • The evolution of full stack engineers
  • One of the best ways to get value for AI coding tools: generating tests
  • Featured on Meta
  • Bringing clarity to status tag usage on meta sites
  • Join Stack Overflow’s CEO and me for the first Stack IRL Community Event in...
  • Feedback requested: How do you use tag hover descriptions for curating and do...
  • Staging Ground Reviewer Motivation
  • What does a new user need in a homepage experience on Stack Overflow?

Hot Network Questions

  • Children's book about intelligent bears or maybe cats
  • How to fold or expand the wingtips on Boeing 777?
  • What sci-fi show was Ernie watching in the show My Three Sons?
  • The quest for a Wiki-less Game
  • Understanding the parabolic state of a quantum particle in the infinite square well
  • Why would the GPL be viral, while EUPL isn't, according to the EUPL authors?
  • Is the product of two NONZERO elements independently drawn from a prime field uniformly distributed?
  • Starting with 2014 "+" signs and 2015 "−" signs, you delete signs until one remains. What’s left?
  • Could they free up a docking port on ISS by undocking the emergency vehicle and letting it float next to the station for a little while
  • Can I land on the "EuroAirport Basel-Mulhouse-Freiburg" with a German National Visa as first destination (NON-EU Citizen)?
  • Is this a misstatement of Euclid in Halmos' Naive Set Theory book?
  • Does Poincare recurrence show that Gibbs entropy is not strictly increasing?
  • What is vi command package?
  • What is the least number of colours Peter could use to color the 3x3 square?
  • About Jesus's reading of Isaiah in the synagogue
  • Why public key is taken in private key in Kyber KEM?
  • Why wasn't Randall Stevens caught?
  • Can't identify logo for a 135N68A MOSFET. Hunting for datasheet. Any ideas?
  • jq - ip addr show in tabular format
  • Paragraph indents dissapeared suddenly
  • Expansion in Latex3 when transforming an input and forwarding it to another function
  • Does a Debt Exist for A Parking Charge Notice
  • The pronoun in short yes/no answers to rhetorical tag-questions with the generic "you"
  • Big Transition of Binary Counting in perspective of IEEE754 floating point

error assignment of read only member c

IMAGES

  1. C++学习 十一、const, mutable关键字_error: assignment of read-only location-CSDN博客

    error assignment of read only member c

  2. assignment of member 'port' in read-only object

    error assignment of read only member c

  3. [Solved] C#

    error assignment of read only member c

  4. C语言 const详解

    error assignment of read only member c

  5. [Solved] c++ error "member function declared with

    error assignment of read only member c

  6. Types of Errors in C

    error assignment of read only member c

VIDEO

  1. Assignment Operator in C Programming

  2. C++ Variables, Literals, an Assignment Statements [2]

  3. error: assignment of read-only variable

  4. C++ : namespace "std" has no member "clamp"

  5. ERROR: Account Requires an assignment to a Co. Object

  6. How to Fix Class Not Registered Error in Windows 11 and Windows 10

COMMENTS

  1. c

    For any struct where you have a const member, you can only set the member when you initialize the struct. You cannot change it in run-time, for the very same reasons as you cant do this: const int x=1; x=2; You have created an immutable object.. Since you aren't allowed to use non-constant function pointers, the function ResetFsm doesn't make any sense and needs to be removed.

  2. c++

    There are three alternatives that you can follow here: don't modify the member. don't mark the function const. make packet_generating_rate mutable. The first two options are the common ones: either the function is const and does not modify the object, or it is not const and can modify the object.

  3. Error: Assignment of read-only variable in C

    Error: Assignment of read-only variable in C

  4. 113454

    (In reply to Maciej W. Rozycki from comment #0) > Filing this bug then for the C++ experts to decide, and if nothing else for > posterity, so that the next person who comes across this build failure can > find it and save themselves from repeating my investigation. Didn't help this time ;) *** This bug has been marked as a duplicate of bug 111544 ***

  5. NVIDIA driver error: assignment of read-only member 'vm_flags'

    1. I installed NVIDIA driver based on this suggesiton using the following command: sudo ubuntu-drivers autoinstall. The above command installed nvidia-driver-535 (535.154.05-0ubuntu0.22.04.1) and other tools. Next, I tried installing CUDA but the installer throws the following error:

  6. error: assignment of data-member ... in read-only structure

    The idea is now: if the methode OsiCsdpSolverInterface::getObjCoefficients () is called, I first delete the old informations of objCoeff because they are no longer important and then I update the new information to return this array. But the compiler says: error: assignment of data-member 'OsiCsdpSolverInterface::objCoeff' in read-only structure.

  7. Build failure: error: assignment of read-only member 'rapidjson

    Build failure: error: assignment of read-only member 'rapidjson::GenericStringRef<CharType>::length' #884. Closed barracuda156 opened this issue Aug 2, 2024 · 2 comments Closed Build failure: error: assignment of read-only member 'rapidjson::GenericStringRef<CharType>::length' #884.

  8. Error: assignment of i_value in read-only object

    Error: assignment of i_value in read-only object; Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems; ... 162|error: assignment of member 'i_value' in read-only object| For some reason I can't upload the other program. No errors but it doesn't appear in the Attachment Manager.

  9. assignment of read-only member 'vm_flags' #267

    Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

  10. Readonly class variables in C++

    This is not read-only. This is writing. A read-only variable( or const) cannot change it's value. It's like R.O.M( Read-Only Memory ). A way to make sure a variable never changes it's value: static const int Variable( 5 ); .

  11. C++

    Best Answer. bool Traffic_source::can_send(void) const. As other's have already pointed out, the problem is that inside a const function (last const in the line) you cannot modify the members of the object. Effectively the member function is translated into something similar to: bool Traffic_source__can_send( const Traffic_source* this, void ...

  12. [Bug c++/113454] New: [14 regression] "assignment of read-only member

    Now this is somewhat old code, which however used to build for at least 17 years. Intuitively, given the `const' member annotation an assignment to it outside a constructor is rightfully rejected, however my C++-fu is not strong enough to back up such a claim and I can't find the relevant C++ language standard clause either way.

  13. c

    2. You declared the parameter as const then you cannot modify it. If the intention is to modify you should not use this modifier. You may have other code problems, but these specific errors are generated by this. Since you created a guy with typedef, could have used it in the parameter declaration.

  14. Assigning value to read-only member

    On top of this, you must either declare a default constructor for Pump or explicitly call the defined constructor in the ElectricPump class. Note that the initializer list is ran before construction of the object, so const members can be set in that. To fix your issue, use this: ElectricPump::ElectricPump() : Pump(5.0)

  15. Driver 470.182.03 fails to compile with Linux 6.3.1

    I sort of figure that sooner or later the good NVidia folks will test their drivers on latest "stable" Linux. Only a matter of time. I have seen this before and it looks like there are some new memory management code in 6.3.1 with variables and structures that have changed.

  16. Use wrapper functions when modifying vma->vm_flags (Linux kernel > 6.3)

    Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

  17. problem with gcc trunck (gcc 15.0.0) #2277

    blackgolfer commented on May 8. rapidjson/document.h:319:82: error: assignment of read-only member 'rapidjson::GenericStringRef::length'. The text was updated successfully, but these errors were encountered: 👍 2. GeckoEidechse and lahwaacz reacted with thumbs up emoji.

  18. c++

    Your optimisation is useless and will result in the exact same code. All of readonly is trivial and will be inlined, eliminating any overhead it might have over using raw T. So, the solution is to not fix a problem that doesn't exist, and just use readonly<int, A> regardless of whether this is debug build or not.. As @MooingDuck noted, you should change your constructor to use init list (and ...

  19. c++

    Objects in a set are immutable; if you want to modify an object, you need to: make a copy of the object from the set, modify the copy, remove the original object from the set, and. insert the copy into the set. It will look something like this: std::set<int> s; s.insert(1); int x = *s.begin(); // (1)

  20. C++ : Error in assignment of member in read-only object

    C++ : Error in assignment of member in read-only objectTo Access My Live Chat Page, On Google, Search for "hows tech developer connect"Here's a secret featur...

  21. [BUG] assignment of read-only member -- occurs with cython tuple

    Log and format.c.txt from 3.0.0 but I confirmed that it also occurs in main branch. log.txt; format.c.txt; Expected behaviour. that it compiles. I worked around it by using a list comprehension before the tuple call. OS. Linux. Python version. 3.9.16. Cython version. main or 3.0.0 (conda-forge) Additional context. No response

  22. c++

    Note: C++ does not support default-int 1>Done building project "eval_if_compilation.vcxproj" -- FAILED. I'm pretty sure that the reason is related to extract_parameter::iterator type definition. When I replaced it with simply unspecified structure it compiles well. I belive that the reason is that it cannot find iterator::type type. However it ...